module Credible::User
Public Instance Methods
authenticate(params)
click to toggle source
# File lib/credible/user.rb, line 47 def authenticate(params) user = find_by_login(params[:login]) user&.authenticate(params[:password]) end
confirm(token = nil)
click to toggle source
End custom password validation
# File lib/credible/user.rb, line 23 def confirm(token = nil) if ActiveSupport::SecurityUtils.secure_compare(token, confirmation_token) self.confirmation_token = nil self.password = SecureRandom.hex(8) unless password_digest.present? self.confirmed_at = Time.now.utc end end
confirmed?()
click to toggle source
# File lib/credible/user.rb, line 31 def confirmed? confirmed_at.present? end
find_by_login(login)
click to toggle source
# File lib/credible/user.rb, line 43 def find_by_login(login) find_by(email: login) end
reset_password()
click to toggle source
# File lib/credible/user.rb, line 35 def reset_password self.password_digest = nil self.confirmed_at = nil regenerate_confirmation_token end