Redirect to password reset in case of existing user
This commit is contained in:
parent
b08e405784
commit
d6c76ceff7
2 changed files with 12 additions and 1 deletions
|
|
@ -3,6 +3,17 @@
|
|||
class RegistrationsController < Devise::RegistrationsController
|
||||
prepend_before_action :check_captcha, only: [:create]
|
||||
|
||||
def create
|
||||
existing_user = User.find_by(email: sign_up_params[:email])
|
||||
if existing_user
|
||||
flash[:notice] = 'An account with this email already exists. Please reset your password to sign in.'
|
||||
redirect_to new_user_password_path(user: { email: sign_up_params[:email] })
|
||||
return
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def after_update_path_for(resource)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
.form-group
|
||||
= f.label :email, "Email"
|
||||
%abbr{title: 'This field is required'} *
|
||||
= f.email_field :email, autofocus: true, required: true, class: 'form-control', placeholder: 'Email'
|
||||
= f.email_field :email, autofocus: true, required: true, class: 'form-control', placeholder: 'Email', value: params.dig(:user, :email)
|
||||
%p.text-right
|
||||
%button{type: 'submit', class: 'btn btn-success'}
|
||||
Send me reset password instructions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue