You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
32 lines
1.0 KiB
3 years ago
|
class Auth::PasswordsController < Devise::PasswordsController
|
||
3 years ago
|
include Helpers::Email
|
||
|
|
||
3 years ago
|
def reset_confirmation
|
||
3 years ago
|
self.resource = resource_class.new
|
||
3 years ago
|
@email = params["email"]
|
||
3 years ago
|
if @email.empty?
|
||
|
resource.errors.add :email, "Enter an email address"
|
||
|
render "devise/passwords/new", status: :unprocessable_entity
|
||
|
elsif !email_valid?(@email)
|
||
|
resource.errors.add :email, "Enter an email address in the correct format, like name@example.com"
|
||
|
render "devise/passwords/new", status: :unprocessable_entity
|
||
|
else
|
||
|
flash[:notice] = "Reset password instructions have been sent to #{@email}"
|
||
|
render "devise/confirmations/reset"
|
||
|
end
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
3 years ago
|
def create
|
||
|
self.resource = resource_class.send_reset_password_instructions(resource_params)
|
||
|
yield resource if block_given?
|
||
|
|
||
|
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
|
||
|
end
|
||
|
|
||
3 years ago
|
protected
|
||
3 years ago
|
|
||
3 years ago
|
def after_sending_reset_password_instructions_path_for(_resource)
|
||
3 years ago
|
confirmations_reset_path(email: params.dig("user", "email"))
|
||
3 years ago
|
end
|
||
|
end
|