Class: UserTemplates::PasswordResetController

Inherits:
Volt::ModelController
  • Object
show all
Defined in:
app/user_templates/controllers/password_reset_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
# File 'app/user_templates/controllers/password_reset_controller.rb', line 5

def index
  self.user = store.users.buffer
  user.password = ''
end

#reset_passwordObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/user_templates/controllers/password_reset_controller.rb', line 10

def reset_password
  self.errors = nil
  user.mark_all_fields!
  user.validate!.fail do |errs|
    # .validate! changed with the sql branch, so we support both versions
    # here
    unless errs[:password]
      PasswordResetTasks.reset_password(params._user_id, params._token, user.password).then do
        flash._notices << 'Password updated'
        user.password = ''

        redirect_to '/'
      end.fail do |err|
        self.errors = err
      end
    end
  end
end