diff options
author | Julian Pawlowski <julian.pawlowski@gmail.com> | 2013-01-28 14:17:52 +0100 |
---|---|---|
committer | Julian Pawlowski <julian.pawlowski@gmail.com> | 2013-01-28 14:17:52 +0100 |
commit | 8aa7de2636dcd22781b623d5c9270f5ecf8b85c2 (patch) | |
tree | 1bb5dc36fb28c96ad9be9a2357d380c2c24ee31e /app/models/user.rb | |
parent | 39aa7132ceed3d4beab3a9b828e571bbfc67c07e (diff) | |
parent | 600574759573e48da9f5f82d4ff8a863b6830c95 (diff) |
Merge branch 'develop'5.1-beta2
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index b902b99..afb3f04 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -95,6 +95,8 @@ class User < ActiveRecord::Base before_destroy :destroy_or_logout_phones + after_save :become_a_member_of_default_user_groups + def destroy clean_whitelist_entries super @@ -142,6 +144,9 @@ class User < ActiveRecord::Base self.pin_hash == Digest::SHA2.hexdigest( "#{self.pin_salt}#{entered_pin}" ) end + def admin? + self.user_groups.include?(UserGroup.find(2)) + end private @@ -207,4 +212,12 @@ class User < ActiveRecord::Base end end + # Normaly a new user should become a member of default user groups. + # + def become_a_member_of_default_user_groups + UserGroup.where(:id => GsParameter.get('DEFAULT_USER_GROUPS_IDS')).each do |user_group| + user_group.user_group_memberships.create(:user_id => self.id) + end + end + end |