Class: UserTemplates::LoginController
- Inherits:
-
Volt::ModelController
- Object
- Volt::ModelController
- UserTemplates::LoginController
- Defined in:
- app/user_templates/controllers/login_controller.rb
Instance Method Summary collapse
- #after_login ⇒ Object
- #do_login ⇒ Object
- #forgot_url ⇒ Object
- #send_reset_email ⇒ Object
- #use_username? ⇒ Boolean
Instance Method Details
#after_login ⇒ Object
25 26 27 |
# File 'app/user_templates/controllers/login_controller.rb', line 25 def after_login redirect_to(attrs.post_login_url || '/') end |
#do_login ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/user_templates/controllers/login_controller.rb', line 9 def do_login Volt.login(login, password).then do |res| # Successful login, clear out the form self.errors = nil self.login = '' self.password = '' after_login nil end.fail do |errors| # Login fail self.errors = errors end end |
#forgot_url ⇒ Object
29 30 31 |
# File 'app/user_templates/controllers/login_controller.rb', line 29 def forgot_url url_for(component: 'user_templates', controller: 'login', action: 'forgot') end |
#send_reset_email ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/user_templates/controllers/login_controller.rb', line 33 def send_reset_email UserTemplateTasks.send_reset_email(reset_email).then do self.reset_email = '' flash._notices << 'Reset email sent.' redirect_to(attrs.post_forgot_url || '/login') end.fail do |err| flash._errors << err. end end |
#use_username? ⇒ Boolean
43 44 45 |
# File 'app/user_templates/controllers/login_controller.rb', line 43 def use_username? Volt.config.public.try(:auth).try(:use_username) end |