diff options
Diffstat (limited to 'app/controllers/otp_enrollments_controller.rb')
| -rw-r--r-- | app/controllers/otp_enrollments_controller.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/controllers/otp_enrollments_controller.rb b/app/controllers/otp_enrollments_controller.rb index 7a31d1e1..54b82214 100644 --- a/app/controllers/otp_enrollments_controller.rb +++ b/app/controllers/otp_enrollments_controller.rb | |||
| @@ -15,7 +15,7 @@ class OtpEnrollmentsController < ApplicationController | |||
| 15 | # unattended logged-in session cannot be enrolled onto a stranger's phone. | 15 | # unattended logged-in session cannot be enrolled onto a stranger's phone. |
| 16 | def create | 16 | def create |
| 17 | unless User.authenticate(current_user.login, params[:current_password].to_s) | 17 | unless User.authenticate(current_user.login, params[:current_password].to_s) |
| 18 | flash[:error] = "Wrong password." | 18 | flash[:error] = t("flash.otp.wrong_password") |
| 19 | return redirect_to edit_user_path(current_user) | 19 | return redirect_to edit_user_path(current_user) |
| 20 | end | 20 | end |
| 21 | current_user.begin_otp_enrollment! | 21 | current_user.begin_otp_enrollment! |
| @@ -25,11 +25,10 @@ class OtpEnrollmentsController < ApplicationController | |||
| 25 | # Confirms with the first generated code. | 25 | # Confirms with the first generated code. |
| 26 | def update | 26 | def update |
| 27 | if current_user.confirm_otp_enrollment!(params[:code]) | 27 | if current_user.confirm_otp_enrollment!(params[:code]) |
| 28 | flash[:notice] = "Second factor enabled. The code you just entered is " \ | 28 | flash[:notice] = t("flash.otp.enabled") |
| 29 | "spent -- wait for the next one before logging in with it." | ||
| 30 | redirect_to edit_user_path(current_user) | 29 | redirect_to edit_user_path(current_user) |
| 31 | else | 30 | else |
| 32 | flash.now[:error] = "That code did not match. Rescan or wait for the next code." | 31 | flash.now[:error] = t("flash.otp.code_mismatch_rescan") |
| 33 | render :show | 32 | render :show |
| 34 | end | 33 | end |
| 35 | end | 34 | end |
| @@ -38,11 +37,11 @@ class OtpEnrollmentsController < ApplicationController | |||
| 38 | def destroy | 37 | def destroy |
| 39 | unless User.authenticate(current_user.login, params[:current_password].to_s) && | 38 | unless User.authenticate(current_user.login, params[:current_password].to_s) && |
| 40 | current_user.verify_otp!(params[:code]) | 39 | current_user.verify_otp!(params[:code]) |
| 41 | flash[:error] = "Password or code wrong -- second factor unchanged." | 40 | flash[:error] = t("flash.otp.wrong_credentials") |
| 42 | return redirect_to edit_user_path(current_user) | 41 | return redirect_to edit_user_path(current_user) |
| 43 | end | 42 | end |
| 44 | current_user.disable_otp!(:actor => current_user) | 43 | current_user.disable_otp!(:actor => current_user) |
| 45 | flash[:notice] = "Second factor disabled." | 44 | flash[:notice] = t("flash.otp.disabled") |
| 46 | redirect_to edit_user_path(current_user) | 45 | redirect_to edit_user_path(current_user) |
| 47 | end | 46 | end |
| 48 | end | 47 | end |
