Files
api/app/controllers/users/passwords_controller.rb
T

40 lines
1.2 KiB
Ruby
Raw Normal View History

2026-07-23 10:41:46 -04:00
# frozen_string_literal: true
class Users::PasswordsController < Devise::PasswordsController
2026-09-16 12:41:44 -04:00
# POST /users/password
def create
self.resource = resource_class.send_reset_password_instructions(resource_params)
yield resource if block_given?
2026-07-23 10:41:46 -04:00
2026-09-16 12:41:44 -04:00
if successfully_sent?(resource)
render json: { message: "Password reset instructions sent successfully." }, status: :ok
else
render json: { errors: resource.errors.full_messages }, status: :unprocessable_entity
end
end
2026-07-23 10:41:46 -04:00
2026-09-16 12:41:44 -04:00
# PUT /users/password
def update
self.resource = resource_class.reset_password_by_token(resource_params)
yield resource if block_given?
2026-07-23 10:41:46 -04:00
2026-09-16 12:41:44 -04:00
if resource.errors.empty?
resource.unlock_access! if unlockable?(resource)
render json: { message: "Password updated successfully." }, status: :ok
else
render json: { errors: resource.errors.full_messages }, status: :unprocessable_entity
end
end
2026-07-23 10:41:46 -04:00
# protected
# def after_resetting_password_path_for(resource)
# super(resource)
# end
# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end