GRN2-252: Change to how sign ins are processed (#869)

* Social to local

* Social/Local to Social

* Rubocop fixes

* Added test cases

* Added the ability to clear social uids

* Update admins_controller.rb

* Update admins_controller.rb
This commit is contained in:
Ahmad Farhat
2020-01-22 16:32:56 -05:00
committed by farhatahmad
parent 42e6e4f235
commit 005ec84c73
10 changed files with 181 additions and 3 deletions

View File

@ -56,6 +56,8 @@ class PasswordResetsController < ApplicationController
# Password does not match password confirmation
flash.now[:alert] = I18n.t("password_different_notice")
elsif @user.update_attributes(user_params)
# Clear the user's social uid if they are switching from a social to a local account
@user.update_attribute(:social_uid, nil) if @user.social_uid.present?
# Successfully reset password
return redirect_to root_path, flash: { success: I18n.t("password_reset_success") }
end
@ -66,7 +68,7 @@ class PasswordResetsController < ApplicationController
private
def find_user
@user = User.find_by(email: params[:email])
@user = User.find_by(email: params[:email], provider: @user_domain)
end
def user_params