diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index dbc8dd4..bcaf9b9 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -40,10 +40,10 @@ redirect_to after_sign_up_error_path_for(resource), alert: _('You must accept the terms and conditions to register.') else existing_user = User.find_by_email(sign_up_params[:email]) - if !existing_user.nil? then - if (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? then - @user = existing_user - do_update(false, true) + if !existing_user.nil? # If email exists + if (existing_user.password == "" || existing_user.password.nil?) && existing_user.confirmed_at.nil? # If user has not accepted invitation yet + existing_user.destroy # Only solution for now + super else redirect_to after_sign_up_error_path_for(resource), alert: _('That email address is already registered.') end @@ -91,16 +91,16 @@ end def do_update(require_password = true, confirm = false) - if require_password # user is changing email or password - if current_user.email != params[:user][:email] # if user changing email - if params[:user][:current_password].blank? # password needs to be present + if require_password # user is changing email or password + if current_user.email != params[:user][:email] # if user is changing email + if params[:user][:current_password].blank? # password needs to be present message = _('Please enter your password to change email address.') successfully_updated = false else successfully_updated = current_user.update_with_password(password_update) end - elsif params[:user][:password].present? # user is changing password - successfully_updated = false # shared across first 3 conditions + elsif params[:user][:password].present? # if user is changing password + successfully_updated = false # shared across first 3 conditions if params[:user][:current_password].blank? message = _('Please enter your current password') elsif params[:user][:password_confirmation].blank? @@ -110,10 +110,10 @@ else successfully_updated = current_user.update_with_password(password_update) end - else # potentially unreachable... but I dont like to leave off the else + else # potentially unreachable... but I dont like to leave off the else successfully_updated = current_user.update_with_password(password_update) end - else # password not required + else # password not required successfully_updated = current_user.update_without_password(update_params) end @@ -125,7 +125,7 @@ #render the correct page if successfully_updated if confirm - current_user.skip_confirmation! + current_user.skip_confirmation! # will error out if confirmable is turned off in user model current_user.save! end session[:locale] = current_user.get_locale unless current_user.get_locale.nil?