Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into liz/add-better-erro…
Browse files Browse the repository at this point in the history
…r-handling
  • Loading branch information
liztownd committed Nov 15, 2024
2 parents 448f6b1 + b150d7c commit fc17342
Show file tree
Hide file tree
Showing 4 changed files with 1,069 additions and 1,553 deletions.
25 changes: 14 additions & 11 deletions app/controllers/v1/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def authenticate
def user_login(saml_response)
user_session_form = UserSessionForm.new(saml_response)
raise_saml_error(user_session_form) unless user_session_form.valid?
mhv_unverified_validation(user_session_form)

mhv_unverified_validation(user_session_form.user)
create_user_verification(user_session_form.user)
@current_user, @session_object = user_session_form.persist
set_cookies
after_login_actions
Expand All @@ -158,8 +158,18 @@ def user_login(saml_response)
login_stats(:success)
end

def mhv_unverified_validation(user_session_form)
if html_escaped_relay_state['type'] == 'mhv_verified' && user_session_form.user.loa[:current] < LOA::THREE
def create_user_verification(user)
user_verifier_object = OpenStruct.new({ sign_in: user.identity.sign_in,
mhv_correlation_id: user.mhv_correlation_id,
idme_uuid: user.idme_uuid,
edipi: user.identity.edipi,
logingov_uuid: user.logingov_uuid,
icn: user.icn })
Login::UserVerifier.new(user_verifier_object).perform
end

def mhv_unverified_validation(user)
if html_escaped_relay_state['type'] == 'mhv_verified' && user.loa[:current] < LOA::THREE
mhv_unverified_error = SAML::UserAttributeError::ERRORS[:mhv_unverified_blocked]
Rails.logger.warn("SessionsController version:v1 #{mhv_unverified_error[:message]}")
raise SAML::UserAttributeError.new(message: mhv_unverified_error[:message],
Expand Down Expand Up @@ -398,13 +408,6 @@ def set_cookies
end

def after_login_actions
user_verifier_object = OpenStruct.new({ sign_in: @current_user.identity.sign_in,
mhv_correlation_id: @current_user.mhv_correlation_id,
idme_uuid: @current_user.idme_uuid,
edipi: @current_user.identity.edipi,
logingov_uuid: @current_user.logingov_uuid,
icn: @current_user.icn })
Login::UserVerifier.new(user_verifier_object).perform
Login::AfterLoginActions.new(@current_user).perform
log_persisted_session_and_warnings
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def needs_accepted_terms_of_use
end

def user_verification
@user_verification ||= get_user_verification
@user_verification ||= UserVerification.find_by(id: user_verification_id)
end

def user_account
@user_account ||= user_verification&.user_account
end

def user_verification_id
@user_verification_id ||= user_verification&.id
@user_verification_id ||= get_user_verification&.id
end

def user_account_uuid
Expand Down
Loading

0 comments on commit fc17342

Please sign in to comment.