Class: Rails::Auth::OtpVerificationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Rails::Auth::OtpVerificationsController
- Defined in:
- app/controllers/rails/auth/otp_verifications_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/rails/auth/otp_verifications_controller.rb', line 12 def create user = Rails::Auth.user_class.find(session[:otp_user_id]) if user.verify_otp(params[:otp_code]) session.delete(:otp_user_id) sign_in(user) redirect_to main_app.root_path, notice: "Signed in successfully." else flash.now[:alert] = "Invalid OTP code." render :new, status: :unprocessable_entity end end |
#new ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/rails/auth/otp_verifications_controller.rb', line 6 def new unless session[:otp_user_id] redirect_to new_session_path, alert: "Session expired." end end |