Merge pull request #5848 from OsamaSayegh/fix-social-login-groups

FIX: apply automatic group rules when using social login providers
This commit is contained in:
Guo Xiang Tan
2018-05-23 08:17:42 +08:00
committed by GitHub
4 changed files with 72 additions and 37 deletions

View File

@@ -21,7 +21,10 @@ class UserAuthenticator
end
def finish
authenticator.after_create_account(@user, @session) if authenticator
if authenticator
authenticator.after_create_account(@user, @session)
confirm_email
end
@session = nil
end
@@ -30,11 +33,18 @@ class UserAuthenticator
end
def authenticated?
@session && @session[:email] == @user.email && @session[:email_valid]
@session && @session[:email]&.downcase == @user.email.downcase && @session[:email_valid].to_s == "true"
end
private
def confirm_email
if authenticated?
EmailToken.confirm(@user.email_tokens.first.token)
@user.set_automatic_groups
end
end
def authenticator
if authenticator_name
@authenticator ||= @authenticator_finder.find_authenticator(authenticator_name)