You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After successful 2fa authentication, devise basically for some reason device grabs warning from locale path devise.failure.already_authenticated instead notice from devise.sessions.signed_in
Here's my controller concern:
moduleAuthenticateWithOtpTwoFactorextendActiveSupport::Concerndefauthenticate_with_otp_two_factoruser=self.resource=find_userifuser_params[:otp_attempt].present? && session[:otp_user_id]authenticate_user_with_otp_two_factor(user)elsifuser&.valid_password?(user_params[:password])prompt_for_otp_two_factor(user)endendprivatedefvalid_otp_attempt?(user)user.validate_and_consume_otp!(user_params[:otp_attempt])# || user.invalidate_otp_backup_code!(user_params[:otp_attempt])rescueStandardError=>eRails.logger.errorefalseenddefprompt_for_otp_two_factor(user)@user=usersession[:otp_user_id]=user.idrender'devise/sessions/two_factor'enddefauthenticate_user_with_otp_two_factor(user)ifvalid_otp_attempt?(user)# Remove any lingering user data from loginsession.delete(:otp_user_id)# remember_me(user) if user_params[:remember_me] == '1' we dont use remember me atmuser.save!sign_in(user,event: :authentication)elseflash.now[:alert]='Invalid code.'prompt_for_otp_two_factor(user)endenddefuser_paramsparams.require(:user).permit(:login,:email,:password,:remember_me,:otp_attempt)enddeffind_userifsession[:otp_user_id]User.unscoped.find(session[:otp_user_id])elsifuser_params[:login]User.unscoped.where(email: user_params[:login])&.firstendenddefotp_two_factor_enabled?Tenant.current.has_2fa? && find_user&.otp_required_for_loginendend
The text was updated successfully, but these errors were encountered:
After successful 2fa authentication, devise basically for some reason device grabs warning from locale path devise.failure.already_authenticated instead notice from devise.sessions.signed_in
Here's my controller concern:
The text was updated successfully, but these errors were encountered: