mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 20:32:44 +08:00
DEV: Allow run_second_factor!
to be used before login (#25420)
In a handful of situations, we need to verify a user's 2fa credentials before `current_user` is assigned. For example: login, email_login and change-email confirmation. This commit adds an explicit `target_user:` parameter to the centralized 2fa system so that it can be used for those situations. For safety and clarity, this new parameter only works for anon. If some user is logged in, and target_user is set to a different user, an exception will be raised.
This commit is contained in:
@ -10,12 +10,12 @@ RSpec.describe SecondFactor::AuthManager do
|
||||
end
|
||||
|
||||
def create_manager(action)
|
||||
SecondFactor::AuthManager.new(guardian, action)
|
||||
SecondFactor::AuthManager.new(guardian, action, target_user: user)
|
||||
end
|
||||
|
||||
def create_action(request = nil)
|
||||
request ||= create_request
|
||||
TestSecondFactorAction.new(guardian, request)
|
||||
TestSecondFactorAction.new(guardian, request, target_user: user)
|
||||
end
|
||||
|
||||
def stage_challenge(successful:)
|
||||
|
Reference in New Issue
Block a user