# frozen_string_literal: true class Users::PasswordsController < Devise::PasswordsController # POST /users/password def create self.resource = resource_class.send_reset_password_instructions(resource_params) yield resource if block_given? 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 # PUT /users/password def update self.resource = resource_class.reset_password_by_token(resource_params) yield resource if block_given? 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 # 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