diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-04-12 01:25:18 +0300 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-04-12 01:25:18 +0300 |
commit | 05a611a0918f9a39de4ea3a051c2192c327f778d (patch) | |
tree | bc705037d8c55717c82b895d2ed8e43279e0d17d /lib/gitlab/saml | |
parent | 1d2429af9b0fd4ef1427c7676a50dae4e2cf0ff9 (diff) |
Better control flow and added guard clause.
Diffstat (limited to 'lib/gitlab/saml')
-rw-r--r-- | lib/gitlab/saml/user.rb | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/gitlab/saml/user.rb b/lib/gitlab/saml/user.rb index dd77216be48..dba4bbfc899 100644 --- a/lib/gitlab/saml/user.rb +++ b/lib/gitlab/saml/user.rb @@ -26,15 +26,13 @@ module Gitlab @user ||= build_new_user end - unless @user.nil? - if external_users_enabled? - # Check if there is overlap between the user's groups and the external groups - # setting then set user as external or internal. - if (auth_hash.groups & Gitlab::Saml::Config.external_groups).empty? - @user.external = false - else - @user.external = true - end + if external_users_enabled? && @user + # Check if there is overlap between the user's groups and the external groups + # setting then set user as external or internal. + if (auth_hash.groups & Gitlab::Saml::Config.external_groups).empty? + @user.external = false + else + @user.external = true end end @@ -50,11 +48,8 @@ module Gitlab end def changed? - if gl_user - gl_user.changed? || gl_user.identities.any?(&:changed?) - else - true - end + return true unless gl_user + gl_user.changed? || gl_user.identities.any?(&:changed?) end protected |