Class: Gringotts::VerificationController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Gringotts::VerificationController
- Defined in:
- app/controllers/gringotts/verification_controller.rb
Instance Method Summary collapse
Instance Method Details
#attempt ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/gringotts/verification_controller.rb', line 24 def attempt if accepts_strong_params? @attempt.assign_attributes(attempt_params) else @attempt.update_attributes(code_received: params[:attempt][:code_received]) end @attempt.validate(@gringotts.recent_code) # Need to .dup because .save is going to erase all errors =( @errors = @attempt.errors.dup # after all that, save a record of this attempt @attempt.save if @attempt.successful? # remember that they have been verified @gringotts.verify!(session) # if account was locked before, unlock! @gringotts.unlock! if @gringotts.locked? # this might be the first time they are validating their phone number # therefore confirm the validity only if unconfirmed. ya dig? if @gringotts.confirmed? # normal verification path # TODO: in future, redirect them to wherever they were going before... redirect_to gringotts_engine.success_path else # first-time verification path # mark that their phone number has been confirmed so that 2FA can be used @gringotts.confirm! # kick them to a success page letting them know that 2FA is set up redirect_to gringotts_engine.success_path end elsif @gringotts.should_lock? @gringotts.lock! redirect_to gringotts_engine.locked_path else flash[:gringotts_error] = "Code was incorrect. A new code has been sent to your phone. Please try again." return redirect_to gringotts_engine.verification_path end end |
#index ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/gringotts/verification_controller.rb', line 13 def index @gringotts.deliver_new_code! @code = @gringotts.recent_code.value if @gringotts.opted_in? return render :verify else return render :confirm end end |
#locked ⇒ Object
74 75 |
# File 'app/controllers/gringotts/verification_controller.rb', line 74 def locked end |
#success ⇒ Object
71 72 |
# File 'app/controllers/gringotts/verification_controller.rb', line 71 def success end |