Browse Source

Only redirect to set password if not previously set

pull/580/head
baarkerlounger 3 years ago
parent
commit
de6707dc1e
  1. 10
      app/controllers/auth/confirmations_controller.rb

10
app/controllers/auth/confirmations_controller.rb

@ -7,18 +7,16 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController
if resource.errors.empty? if resource.errors.empty?
set_flash_message!(:notice, :confirmed) set_flash_message!(:notice, :confirmed)
if resource.sign_in_count.zero?
token = resource.send(:set_reset_password_token) token = resource.send(:set_reset_password_token)
base = public_send("edit_#{resource_class.name.underscore}_password_url") base = public_send("edit_#{resource_class.name.underscore}_password_url")
url = "#{base}?reset_password_token=#{token}" url = "#{base}?reset_password_token=#{token}"
redirect_to url redirect_to url
else else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
end end
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end end
protected
def after_confirmation_path_for(resource_name, resource)
edit_user_password_path(email: resource.email)
end end
end end

Loading…
Cancel
Save