@@ -160,16 +160,16 @@ def extract_microsoft_data(auth)
160
160
# Clever/Powerschool signins have unique requirements, and must be handled a bit outside the normal flow
161
161
def handle_untrusted_email_signin ( user , provider )
162
162
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.
173
173
if user . migrated?
174
174
auth_option = user . authentication_options . find_by credential_type : provider
175
175
begin_account_takeover \
@@ -186,8 +186,8 @@ def handle_untrusted_email_signin(user, provider)
186
186
end
187
187
user . seen_oauth_connect_dialog = true
188
188
user . save!
189
- sign_in_user
190
189
end
190
+ sign_in_user
191
191
end
192
192
193
193
def move_oauth_params_to_cache ( user )
0 commit comments