Sha256: df9b98e89793ebd6d9f60963ab0699bd07a28dcd1d515d6106cc40f82dc93ba6
Contents?: true
Size: 829 Bytes
Versions: 8
Compression:
Stored size: 829 Bytes
Contents
class User include Mongoid::Document field :provider, :type => String field :uid, :type => String field :code, :type => String field :email, :type => String field :role, :type => String belongs_to :identity has_many :xmains, :class_name => "Mindapp::Xmain" def has_role(role1) return role.upcase.split(',').include?(role1.upcase) end def self.from_omniauth(auth) where(:provider=> auth["provider"], :uid=> auth["uid"]).first || create_with_omniauth(auth) end 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 def secured? role.upcase.split(',').include?(SECURED_ROLE) end end
Version data entries
8 entries across 8 versions & 1 rubygems