aboutsummaryrefslogtreecommitdiff
path: root/src/actions/password_resets/create.cr
blob: da1e711b194fc8f653f57ee065525b3abe39d91b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class PasswordResets::Create < BrowserAction
  include Auth::PasswordResets::Base
  include Auth::PasswordResets::TokenFromSession

  post "/password_resets/:user_id" do
    ResetPassword.update(user, params) do |operation, user|
      if operation.saved?
        session.delete(:password_reset_token)
        sign_in user
        flash.success = "Your password has been reset"
        redirect to: Home::Index
      else
        html NewPage, operation: operation, user_id: user_id.to_i64
      end
    end
  end
end