DEV: Add code comments around oauth user-api-key/new handling (#31774)

Followup to #31759
This commit is contained in:
Penar Musaraj
2025-03-12 14:01:20 -04:00
committed by GitHub
parent f2fda8e8b9
commit 897b043f01
2 changed files with 5 additions and 1 deletions

View File

@ -87,6 +87,9 @@ class Users::OmniauthCallbacksController < ApplicationController
cookies["_bypass_cache"] = true
cookies[:authentication_data] = { value: client_hash.to_json, path: Discourse.base_path("/") }
# If the user account doesn't already exist, and this signup is part of a user-api-key request, direct
# the user to the homepage first so that signup can be completed. They'll be redirected to the user-api-key
# route once signup is complete. Hopefully, this can be simplified once fullscreen login/signup is everywhere.
if !current_user && @origin.start_with?("/user-api-key/new")
redirect_to path("/")
else

View File

@ -124,7 +124,8 @@ class Auth::Result
AssociatedGroup.where(id: associated_group_ids).update_all("last_used = CURRENT_TIMESTAMP")
end
Group.user_trust_level_change!(user.id, user.trust_level) if user && !user.staged
# refreshes automatic group membership (despite the name, it doesn't change TLs)
Group.user_trust_level_change!(user.id, user.trust_level) if user
end
def can_edit_name