Class: Mks::Auth::User
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Mks::Auth::User
- Defined in:
- app/models/mks/auth/user.rb
Overview
A model class to represent users of the system
Constant Summary collapse
- VALID_EMAIL_REGEX =
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
Instance Method Summary collapse
Instance Method Details
#full_name ⇒ Object
23 24 25 |
# File 'app/models/mks/auth/user.rb', line 23 def full_name "#{first_name} #{last_name}" end |
#has_module(code) ⇒ Object
35 36 37 38 39 |
# File 'app/models/mks/auth/user.rb', line 35 def has_module(code) app_module = ApplicationModule.find_by(code: code) roles = self.roles.select { |ur| ur.application_module == app_module } roles.count.positive? end |
#role_names ⇒ Object
27 28 29 |
# File 'app/models/mks/auth/user.rb', line 27 def role_names roles.map(&:name) end |
#to_token_payload ⇒ Object
31 32 33 |
# File 'app/models/mks/auth/user.rb', line 31 def to_token_payload { id: id, email: email, name: full_name, roles: role_names } end |