Module: Authpwn::UserModel

Extended by:
ActiveSupport::Concern
Included in:
User
Defined in:
lib/authpwn_rails/user_model.rb

Overview

Included by the model class that represents users.

Parts of the codebase assume the model will be named User.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#auth_bounce_reason(crdential) ⇒ Object

Checks if a credential is acceptable for authenticating a user.

Returns nil if the credential is acceptable, or a String containing a user-visible reason why the credential is not acceptable.



102
103
104
# File 'lib/authpwn_rails/user_model.rb', line 102

def auth_bounce_reason(crdential)
  nil
end

#set_default_exuidObject

:nodoc: sets exuid to a (hopefully) unique value before validations occur.



112
113
114
115
# File 'lib/authpwn_rails/user_model.rb', line 112

def set_default_exuid
  self.exuid ||=
      Base32.encode(SecureRandom.random_bytes(16)).downcase.sub(/=*$/, '')
end

#to_paramObject

Use e-mails instead of exposing ActiveRecord IDs.



107
108
109
# File 'lib/authpwn_rails/user_model.rb', line 107

def to_param
  exuid
end