FIX: display warning when SSO email is different from invite email (#13804)

In this commit, we skipped frontend validation when email is obfuscated:
https://github.com/discourse/discourse/commit/534008ba24c

However, if email from SSO is different from email from invite, we should still display warning.
This commit is contained in:
Krzysztof Kotlarek
2021-07-21 17:03:04 +10:00
committed by GitHub
parent 7162ecfb04
commit 40f6ceb6f2
3 changed files with 48 additions and 4 deletions

View File

@ -50,10 +50,13 @@ class InvitesController < ApplicationController
email = Email.obfuscate(invite.email)
# Show email if the user already authenticated their email
different_external_email = false
if session[:authentication]
auth_result = Auth::Result.from_session_data(session[:authentication], user: nil)
if invite.email == auth_result.email
email = invite.email
else
different_external_email = true
end
end
@ -73,6 +76,10 @@ class InvitesController < ApplicationController
email_verified_by_link: email_verified_by_link
}
if different_external_email
info[:different_external_email] = true
end
if staged_user = User.where(staged: true).with_email(invite.email).first
info[:username] = staged_user.username
info[:user_fields] = staged_user.user_fields