Class: EmailAuthenticationsController
- Inherits:
-
NoPassword::EmailAuthenticationsController
- Object
- ApplicationController
- NoPassword::EmailAuthenticationsController
- EmailAuthenticationsController
- Defined in:
- lib/generators/nopassword/install/templates/controller.rb
Instance Method Summary collapse
-
#deliver_authentication(authentication) ⇒ Object
Override with your own logic to deliver a code to the user.
-
#verification_exceeded_attempts(verification) ⇒ Object
Override with logic for when verification attempts are exceeded.
-
#verification_expired(verification) ⇒ Object
Override with logic for when verification has expired.
-
#verification_succeeded(email) ⇒ Object
Override with your own logic to do something with the valid data.
Methods inherited from NoPassword::EmailAuthenticationsController
#create, #destroy, #new, #show, #update
Instance Method Details
#deliver_authentication(authentication) ⇒ Object
Override with your own logic to deliver a code to the user.
32 33 34 |
# File 'lib/generators/nopassword/install/templates/controller.rb', line 32 def deliver_authentication(authentication) NoPassword::EmailAuthenticationMailer.with(authentication: authentication).notification_email.deliver end |
#verification_exceeded_attempts(verification) ⇒ Object
Override with logic for when verification attempts are exceeded. For example, you might want to tweak the flash message that’s displayed or redirect them to a page other than the one where they’d re-verify.
18 19 20 21 |
# File 'lib/generators/nopassword/install/templates/controller.rb', line 18 def verification_exceeded_attempts(verification) flash[:nopassword_status] = "The number of times the code can be tried has been exceeded." redirect_to url_for(action: :new) end |
#verification_expired(verification) ⇒ Object
Override with logic for when verification has expired. For example, you might want to tweak the flash message that’s displayed or redirect them to a page other than the one where they’d re-verify.
26 27 28 29 |
# File 'lib/generators/nopassword/install/templates/controller.rb', line 26 def verification_expired(verification) flash[:nopassword_status] = "The code has expired." redirect_to url_for(action: :new) end |
#verification_succeeded(email) ⇒ Object
Override with your own logic to do something with the valid data. For example, you might setup the current user session here via:
“‘ def verification_succeeded(email)
self.current_user = User.find_or_create_by(email: email)
redirect_to dashboard_url
end “‘
11 12 13 |
# File 'lib/generators/nopassword/install/templates/controller.rb', line 11 def verification_succeeded(email) redirect_to root_url end |