Skip to content

Commit 6f0924e

Browse files
committed
Streamline email confirmation for SSO sign-in
Commit 6af91b6 streamlined the email confirmation process for unconfirmed users with no confirmation_token. Specifically, it targeted users attempting to sign in via the app's standard sign-in form. This change applies the same streamlining to users attempting to sign in via SSO/Shibboleth. Specifically, when a user attempts to sign in this way, the `.confirmed_or_has_confirmation_token?` is performed on them. If it returns false, then the confirmation_token is generated for the user and they are auto-sent a confirmation instructions email. (Refer to commit 6af91b6 for more regarding this streamlined process.)
1 parent 1ceeec0 commit 6f0924e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/controllers/users/omniauth_callbacks_controller.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def handle_omniauth(scheme)
4040
# Otherwise sign them in
4141
elsif scheme.name == 'shibboleth'
4242
# Until ORCID becomes supported as a login method
43+
unless existing_user.confirmed_or_has_confirmation_token?
44+
handle_missing_confirmation_instructions(existing_user)
45+
return
46+
end
4347
set_flash_message(:notice, :success, kind: scheme.description) if is_navigational_format?
4448
sign_in_and_redirect user, event: :authentication
4549
else
@@ -83,4 +87,14 @@ def failure
8387
redirect_to root_path
8488
end
8589
end
90+
91+
private
92+
93+
def handle_missing_confirmation_instructions(user)
94+
# Generate a confirmation_token and email confirmation instructions to the user
95+
user.send_confirmation_instructions
96+
# Notify the user they are unconfirmed but confirmation instructions have been sent
97+
flash[:notice] = I18n.t('devise.registrations.signed_up_but_unconfirmed')
98+
redirect_to root_path
99+
end
86100
end

0 commit comments

Comments
 (0)