mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Add description to the 2FA page when adding new admins (#16098)
This PR adds an extra description to the 2FA page when granting a user admin access. It also introduces a general system for adding customized descriptions that can be used by future actions.
(Follow-up to dd6ec65061)
This commit is contained in:
@@ -9,9 +9,14 @@ module SecondFactor::Actions
|
||||
|
||||
def second_factor_auth_required!(params)
|
||||
user = find_user(params[:user_id])
|
||||
description = I18n.t(
|
||||
"second_factor_auth.actions.grant_admin.description",
|
||||
username: "@#{user.username}"
|
||||
)
|
||||
{
|
||||
callback_params: { user_id: user.id },
|
||||
redirect_path: admin_user_show_path(id: user.id, username: user.username)
|
||||
redirect_path: admin_user_show_path(id: user.id, username: user.username),
|
||||
description: description
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ the following methods:
|
||||
redirected to after the action is finished. When this key is omitted, the
|
||||
redirect path is set to the homepage (/).
|
||||
|
||||
:description => optional action-specific description message that's shown on
|
||||
the 2FA page.
|
||||
|
||||
After this method is called, the auth manager will send a 403 response with a
|
||||
JSON body. It does that by raising an exception that's then rescued by a
|
||||
`rescue_from` handler. The JSON response contains a challenge nonce which the
|
||||
@@ -169,6 +172,9 @@ class SecondFactor::AuthManager
|
||||
allowed_methods: allowed_methods.to_a,
|
||||
generated_at: Time.zone.now.to_i
|
||||
}
|
||||
if config[:description]
|
||||
challenge[:description] = config[:description]
|
||||
end
|
||||
secure_session["current_second_factor_auth_challenge"] = challenge.to_json
|
||||
nonce
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user