Class: RailsIdentity::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RailsIdentity::User
- Includes:
- Repia::UUIDModel
- Defined in:
- app/models/rails_identity/user.rb
Instance Method Summary collapse
-
#default_role ⇒ Object
Sets the default the role for the user if not set.
-
#initialize(attributes = {}) ⇒ User
constructor
Initializes the user.
-
#issue_token(kind) ⇒ Object
This method will generate a reset token that lasts for an hour.
Constructor Details
#initialize(attributes = {}) ⇒ User
Initializes the user. User is not verified initially. The user has one hour to get verified. After that, a PATCH request must be made to re-issue the verification token.
20 21 22 23 |
# File 'app/models/rails_identity/user.rb', line 20 def initialize(attributes = {}) attributes[:api_key] = SecureRandom.hex(32) super end |
Instance Method Details
#default_role ⇒ Object
Sets the default the role for the user if not set.
28 29 30 |
# File 'app/models/rails_identity/user.rb', line 28 def default_role self.role ||= Roles::USER end |
#issue_token(kind) ⇒ Object
This method will generate a reset token that lasts for an hour.
35 36 37 38 39 40 41 42 43 |
# File 'app/models/rails_identity/user.rb', line 35 def issue_token(kind) session = Session.new(user: self, seconds: 3600) session.save if kind == :reset_token self.reset_token = session.token elsif kind == :verification_token self.verification_token = session.token end end |