Skip to content
Snippets Groups Projects
Commit 8bc4597c authored by Achilleas Pipinellis's avatar Achilleas Pipinellis
Browse files

Merge branch 'master' into 'master'

added ability to connect existing accounts

The old code only authenticate if user already has gl_uid in the plugin store, now if the user does not have it and tried to login with gitlab, it checks if there is any user with the same email as gitlab, adds gl_uid for that user then logs in.


See merge request !2
parents 2b756879 2b2016eb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -26,9 +26,15 @@ class GitLabAuthenticator < ::Auth::Authenticator
# Plugin specific data storage
current_info = ::PluginStore.get("gl", "gl_uid_#{gl_uid}")
 
result.user =
if current_info
User.where(id: current_info[:user_id]).first
# Check if the user is trying to connect existing account
unless current_info
existing_user = User.where(email: email).first
if existing_user
::PluginStore.set("gl", "gl_uid_#{data[:gl_uid]}", {user_id: existing_user.id })
result.user = existing_user
end
else
result.user = User.where(id: current_info[:user_id]).first
end
 
result.name = name
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment