From d20968afa56dd3723d9833685e232a3081053e69 Mon Sep 17 00:00:00 2001 From: Ward Vandewege Date: Thu, 6 Nov 2014 10:23:11 -0500 Subject: [PATCH] Update the behavior of the auto_admin_user configuration field a bit to make it more intuitive: the first user created with an e-mail address that matches auto_admin_user will now become admin, regardless of the presence of other admin users. Any subsequent accounts created with that e-mail address will no longer become admin. refs #4383 --- services/api/app/models/user.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb index 3b201b5bab..b939d07bf0 100644 --- a/services/api/app/models/user.rb +++ b/services/api/app/models/user.rb @@ -234,13 +234,13 @@ class User < ArvadosModel end def check_auto_admin - if not self.uuid.end_with?('anonymouspublic') and - User.where("uuid not like '%-000000000000000'").where(:is_admin => true).count == 0 - if (Rails.configuration.auto_admin_user and self.email == Rails.configuration.auto_admin_user) or - Rails.configuration.auto_admin_first_user - self.is_admin = true - self.is_active = true - end + return if self.uuid.end_with?('anonymouspublic') + if (User.where("email = ?",self.email).where(:is_admin => true).count == 0 and + Rails.configuration.auto_admin_user and self.email == Rails.configuration.auto_admin_user) or + (User.where("uuid not like '%-000000000000000'").where(:is_admin => true).count == 0 and + Rails.configuration.auto_admin_first_user) + self.is_admin = true + self.is_active = true end end -- 2.30.2