app/models/user.rb in mix-rails-auth-0.16.0 vs app/models/user.rb in mix-rails-auth-0.22.0
- old
+ new
@@ -1,12 +1,12 @@
class User
include Mongoid::Document
+ rolify
+ include Authority::UserAbilities
- ROLES = %w[admin content_manager]
+ ROLES = %w[admin manager]
- #attr_accessible :roles
-
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable,
:trackable, :validatable, :registerable
@@ -44,25 +44,9 @@
# field :unlock_token, :type => String # Only if unlock strategy is :email or :both
# field :locked_at, :type => Time
## Token authenticatable
# field :authentication_token, :type => String
-
-
- #field :role, :type => String
- field :roles_mask, :type => Integer
-
- def roles=(roles)
- self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.inject(0, :+)
- end
-
- def roles
- ROLES.reject do |r|
- ((roles_mask || 0) & 2**ROLES.index(r)).zero?
- end
- end
-
- def is?(role)
- roles.include?(role.to_s)
- end
+
+ #has_and_belongs_to_many :roles
end