has_many :api_client_authorizations
before_update :prevent_privilege_escalation
before_update :prevent_inactive_admin
+ before_create :check_auto_admin
after_create AdminNotifier
has_many :authorized_keys, :foreign_key => :authorized_user_uuid, :primary_key => :uuid
- api_accessible :superuser, :extend => :common do |t|
+ api_accessible :user, extend: :common do |t|
t.add :email
t.add :full_name
t.add :first_name
next if target_uuid == self.uuid
next if (group_permissions[target_uuid] and
group_permissions[target_uuid][action])
- if target.respond_to? :owner
- next if target.owner == self.uuid
- next if (group_permissions[target.owner] and
- group_permissions[target.owner][action])
+ if target.respond_to? :owner_uuid
+ next if target.owner_uuid == self.uuid
+ next if (group_permissions[target.owner_uuid] and
+ group_permissions[target.owner_uuid][action])
end
return false
end
self.is_active == Rails.configuration.new_users_are_active)
end
+ def check_auto_admin
+ if User.where("uuid not like '%-000000000000000'").where(:is_admin => true).count == 0 and not Rails.configuration.auto_admin_user.nil?
+ if current_user.email == Rails.configuration.auto_admin_user
+ self.is_admin = true
+ self.is_active = true
+ end
+ end
+ end
+
def prevent_privilege_escalation
if current_user.andand.is_admin
return true