Sha256: 250cd0c756dff6e403d49b8df8588d132bff543d7e56800139e06334464ecd86
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
class <%= class_name %> < ApplicationRecord has_secure_token :session_token has_secure_password validates :email, presence: true, uniqueness: true validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ } validates_length_of :password, minimum: 8, allow_blank: true before_validation do self.email = email.downcase.strip end after_update_commit do if self.email_previously_changed? EmailMailer.with(change: self.email_previous_change).changed.deliver_later end end after_update_commit do if self.password_digest_previously_changed? PasswordMailer.with(<%= singular_table_name %>: self).changed.deliver_later end end <% if options.api? %> def signed_session_token self.class.signed_id_verifier.generate(session_token) end def self.find_signed_session_token(signed_session_token) if session_token = signed_id_verifier.verified(signed_session_token) find_by_session_token(session_token) end end def as_json(options = {}) super(options.merge(except: [:password_digest, :session_token])) end <% end -%> end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
authentication-zero-0.0.24 | lib/generators/authentication/templates/models/model.rb.tt |
authentication-zero-0.0.23 | lib/generators/authentication/templates/app/models/model.rb.tt |