Sha256: 0568386c1853e82c5018623a42f29c09def244c53e92330e90e128a1bc253a99
Contents?: true
Size: 848 Bytes
Versions: 5
Compression:
Stored size: 848 Bytes
Contents
# frozen_string_literal: true module PasswordCreatable extend ActiveSupport::Concern included do # Virtual attributes attr_reader :is_generated_password # Callbacks after_commit :send_login_info, on: :create before_validation :create_password, on: :create after_initialize do |obj| obj.is_generated_password = false end end protected # Virtual attributes attr_writer :is_generated_password private def create_password return if password.present? password = Devise.friendly_token.first(8) self.password = password self.password_confirmation = password self.is_generated_password = true end def send_login_info login_info_mailer.login_info(id, password).deliver_later! if is_generated_password end def login_info_mailer raise NotImplementedError end end
Version data entries
5 entries across 5 versions & 1 rubygems