Skip to content

Commit

Permalink
ensure the user doesn't already have the role before adding it.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Jul 2, 2010
1 parent 5158967 commit 6fa7872
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vendor/plugins/authentication/app/models/user.rb
Expand Up @@ -59,7 +59,9 @@ def can_delete?(user_to_delete = self)
end

def add_role(role_to_add)
roles << Role[role_to_add]
unless self.has_role?(role = Role[role_to_add])
roles << role
end
end

def has_role?(role)
Expand Down

0 comments on commit 6fa7872

Please sign in to comment.