class UserAuth::Models::User

Attributes

password[R]
password_changing[RW]

Public Instance Methods

clear_refresh_tokens!() click to toggle source
# File lib/user_auth/models/user.rb, line 37
def clear_refresh_tokens!
  refresh_tokens_dataset.destroy
end
email=(email) click to toggle source
Calls superclass method
# File lib/user_auth/models/user.rb, line 25
def email=(email)
  super(email.try(:downcase))
end
password=(plaintext) click to toggle source
# File lib/user_auth/models/user.rb, line 20
def password=(plaintext)
  @password = plaintext
  self.password_digest = PasswordHasher.new.hash_plaintext(plaintext)
end
refresh_token!() click to toggle source
# File lib/user_auth/models/user.rb, line 33
def refresh_token!
  RefreshToken.find_or_create(user: self).token
end
to_json() click to toggle source
# File lib/user_auth/models/user.rb, line 29
def to_json
  info.merge(email: email, user_id: id).symbolize_keys
end
validate() click to toggle source
Calls superclass method
# File lib/user_auth/models/user.rb, line 11
def validate
  super
  validates_presence :email
  validates_unique :email
  validates_format(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :email, message: "is not a valid email address")
  validates_presence :password if new? || password_changing
  validates_min_length 8, :password if new? || password_changing
end