FIX: Make UI match server behavior for external-auth invites (#13113)

There are two methods which the server uses to verify an invite is being redeemed with a matching email:
  1) The email token, supplied via a `?t=` parameter
  2) The validity of the email, as provided by the auth provider

Only one of these needs to be true for the invite to be redeemed successfully on the server. The frontend logic was previously only checking (2). This commit updates the frontend logic to match the server.

This commit does not affect the invite redemption logic. It only affects the 'show' endpoint, and the UI.
This commit is contained in:
David Taylor
2021-05-26 09:47:44 +01:00
committed by GitHub
parent d0dfd0c73f
commit f25eda13fa
5 changed files with 96 additions and 6 deletions

View File

@ -31,6 +31,11 @@ class InvitesController < ApplicationController
end
end
email_verified_by_link = invite.email_token.present? && params[:t] == invite.email_token
if email_verified_by_link
email = invite.email
end
hidden_email = email != invite.email
info = {
@ -38,7 +43,8 @@ class InvitesController < ApplicationController
email: email,
hidden_email: hidden_email,
username: hidden_email ? '' : UserNameSuggester.suggest(invite.email),
is_invite_link: invite.is_invite_link?
is_invite_link: invite.is_invite_link?,
email_verified_by_link: email_verified_by_link
}
if staged_user = User.where(staged: true).with_email(invite.email).first