Sha256: 3b77fc8b489deffb40618ccd047b8bf6c392cf0cda88b0a70eb3730e4fb623be
Contents?: true
Size: 1.06 KB
Versions: 9
Compression:
Stored size: 1.06 KB
Contents
class <%= class_name %> < ApplicationRecord has_secure_password has_many :sessions, dependent: :destroy validates :email, presence: true, uniqueness: true validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/ validates_length_of :password, minimum: 12, allow_blank: true validates_format_of :password, with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/, allow_blank: true, message: "might easily be guessed" <% if options.pwned? -%> validates :password, not_pwned: { message: "might easily be guessed" } <% end -%> before_validation do self.email = email.downcase.strip end before_validation if: :email_changed? do self.verified = false end after_update if: :password_digest_previously_changed? do sessions.where.not(id: Current.session).destroy_all end after_create_commit do IdentityMailer.with(<%= singular_table_name %>: self).email_verify_confirmation.deliver_later end after_update_commit if: :email_previously_changed? do IdentityMailer.with(<%= singular_table_name %>: self).email_verify_confirmation.deliver_later end end
Version data entries
9 entries across 9 versions & 1 rubygems