summaryrefslogtreecommitdiff
path: root/lib/gitlab/auth/o_auth/user.rb
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-18 15:03:27 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-22 23:50:55 +0100
commitf10c999bca2b5b37b068ff3680a6e35a6707828d (patch)
treea517f86544c1544ee25d174652a003fff9b199a0 /lib/gitlab/auth/o_auth/user.rb
parentc212908aad9b32352653dfe9ca966f148c8dfc1a (diff)
downloadgitlab-ce-f10c999bca2b5b37b068ff3680a6e35a6707828d.tar.gz
Refactor OmniauthCallbacksController to remove duplication
Moves LDAP to its own controller with tests Provides path forward for implementing GroupSaml
Diffstat (limited to 'lib/gitlab/auth/o_auth/user.rb')
-rw-r--r--lib/gitlab/auth/o_auth/user.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/auth/o_auth/user.rb b/lib/gitlab/auth/o_auth/user.rb
index d0c6b0386ba..f2923c29163 100644
--- a/lib/gitlab/auth/o_auth/user.rb
+++ b/lib/gitlab/auth/o_auth/user.rb
@@ -30,6 +30,10 @@ module Gitlab
gl_user.try(:valid?)
end
+ def valid_sign_in?
+ valid? && persisted?
+ end
+
def save(provider = 'OAuth')
raise SigninDisabledForProviderError if oauth_provider_disabled?
raise SignupDisabledError unless gl_user
@@ -64,8 +68,18 @@ module Gitlab
user
end
+ def find_and_update!
+ save if omniauth_should_save?
+
+ gl_user
+ end
+
protected
+ def omniauth_should_save?
+ true
+ end
+
def add_or_update_user_identities
return unless gl_user