mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
FIX: Show a nicer error if name/code missing for TOTP/Security Keys (#9124)
Meta: https://meta.discourse.org/t/improve-error-message-when-not-including-name-setting-up-totp/143339 * when the user creates a TOTP second factor method we want to show them a nicer error if they forget to add a name or the code from the app, instead of the param missing error * also add a client-side check for this and for security key name, no need to bother the server if we can help it
This commit is contained in:
@ -1211,8 +1211,12 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def enable_second_factor_totp
|
||||
params.require(:second_factor_token)
|
||||
params.require(:name)
|
||||
if params[:second_factor_token].blank?
|
||||
return render json: failed_json.merge(error: I18n.t("login.missing_second_factor_code"))
|
||||
end
|
||||
if params[:name].blank?
|
||||
return render json: failed_json.merge(error: I18n.t("login.missing_second_factor_name"))
|
||||
end
|
||||
auth_token = params[:second_factor_token]
|
||||
|
||||
totp_data = secure_session["staged-totp-#{current_user.id}"]
|
||||
|
Reference in New Issue
Block a user