Class: User
- Inherits:
-
Object
- Object
- User
- Includes:
- Mongoid::Document
- Defined in:
- lib/generators/mindapp/templates/app/models/user.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create_with_omniauth(auth) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/mindapp/templates/app/models/user.rb', line 17 def self.create_with_omniauth(auth) identity = Identity.find auth.uid create! do |user| user.provider = auth.provider user.uid = auth.uid user.code = identity.code user.email = identity.email user.role = "M" end end |
.from_omniauth(auth) ⇒ Object
14 15 16 |
# File 'lib/generators/mindapp/templates/app/models/user.rb', line 14 def self.from_omniauth(auth) where(:provider=> auth["provider"], :uid=> auth["uid"]).first || create_with_omniauth(auth) end |
Instance Method Details
#has_role(role1) ⇒ Object
11 12 13 |
# File 'lib/generators/mindapp/templates/app/models/user.rb', line 11 def has_role(role1) return role.upcase.split(',').include?(role1.upcase) end |
#secured? ⇒ Boolean
27 28 29 |
# File 'lib/generators/mindapp/templates/app/models/user.rb', line 27 def secured? role.upcase.split(',').include?(SECURED_ROLE) end |