mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +08:00
FEATURE: Implement 2factor login TOTP
implemented review items. Blocking previous codes - valid 2-factor auth tokens can only be authenticated once/30 seconds. I played with updating the “last used” any time the token was attempted but that seemed to be overkill, and frustrating as to why a token would fail. Translatable texts. Move second factor logic to a helper class. Move second factor specific controller endpoints to its own controller. Move serialization logic for 2-factor details in admin user views. Add a login ember component for de-duplication Fix up code formatting Change verbiage of google authenticator add controller tests: second factor controller tests change email tests change password tests admin login tests add qunit tests - password reset, preferences fix: check for 2factor on change email controller fix: email controller - only show second factor errors on attempt fix: check against 'true' to enable second factor. Add modal for explaining what 2fa with links to Google Authenticator/FreeOTP add two factor to email signin link rate limit if second factor token present add rate limiter test for second factor attempts
This commit is contained in:
@ -25,7 +25,8 @@ class Admin::UsersController < Admin::AdminController
|
||||
:generate_api_key,
|
||||
:revoke_api_key,
|
||||
:anonymize,
|
||||
:reset_bounce_score]
|
||||
:reset_bounce_score,
|
||||
:disable_second_factor]
|
||||
|
||||
def index
|
||||
users = ::AdminUserIndexQuery.new(params).find_users
|
||||
@ -340,6 +341,18 @@ class Admin::UsersController < Admin::AdminController
|
||||
}
|
||||
end
|
||||
|
||||
def disable_second_factor
|
||||
guardian.ensure_can_disable_second_factor! @user
|
||||
if @user.user_second_factor.try(:delete)
|
||||
StaffActionLogger.new(current_user).log_disable_second_factor_auth(@user)
|
||||
end
|
||||
Jobs.enqueue(
|
||||
:critical_user_email,
|
||||
type: :account_second_factor_disabled,
|
||||
user_id: @user.id
|
||||
)
|
||||
end
|
||||
|
||||
def destroy
|
||||
user = User.find_by(id: params[:id].to_i)
|
||||
guardian.ensure_can_delete_user!(user)
|
||||
|
Reference in New Issue
Block a user