Skip to content

Commit 3e88171

Browse files
committed
Only show Clever link modal in forced-takeover case
1 parent 299396d commit 3e88171

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

dashboard/app/controllers/omniauth_callbacks_controller.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@ def extract_microsoft_data(auth)
160160
# Clever/Powerschool signins have unique requirements, and must be handled a bit outside the normal flow
161161
def handle_untrusted_email_signin(user, provider)
162162
force_takeover = user.teacher? && user.email.present? && user.email.end_with?('.oauthemailalreadytaken')
163-
164-
# We used to check this based on sign_in_count, but we're explicitly logging it now
165-
seen_oauth_takeover_dialog = (!!user.seen_oauth_connect_dialog) || user.sign_in_count > 1
166-
167-
# If account exists (as looked up by Clever ID) and it's not the first login, just sign in
168-
if user.persisted? && seen_oauth_takeover_dialog && !force_takeover
169-
sign_in_user
170-
else
171-
# Otherwise, it's either the first login, or a user who must connect -
172-
# offer to connect the Clever account to an existing one, or insist if needed
163+
if force_takeover
164+
# It's a user who must link accounts - a Clever/Powerschool Code.org teacher account with an
165+
# email that conflicts with an existing Code.org account.
166+
#
167+
# We don't want them using the teacher account as-is because it doesn't have a valid email.
168+
# We can't do a silent takeover because we don't trust email addresses from Clever/Powerschool
169+
#
170+
# Long-term I'd like sign-up when there's a conflict like this to just fail, with a helpful
171+
# message directing the teacher to sign in to their existing account and then link Clever
172+
# to it from the accounts page.
173173
if user.migrated?
174174
auth_option = user.authentication_options.find_by credential_type: provider
175175
begin_account_takeover \
@@ -186,8 +186,8 @@ def handle_untrusted_email_signin(user, provider)
186186
end
187187
user.seen_oauth_connect_dialog = true
188188
user.save!
189-
sign_in_user
190189
end
190+
sign_in_user
191191
end
192192

193193
def move_oauth_params_to_cache(user)

0 commit comments

Comments
 (0)