Skip to content

Commit

Permalink
Minor refactor in OmniAuthCallbacksController
Browse files Browse the repository at this point in the history
Use memoization instead of local variable assignment.
  • Loading branch information
malcolmbaig committed Nov 9, 2023
1 parent 1c307e5 commit f2f5c75
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ def dfe
if DfESignIn.bypass?
create_or_update_dsi_user
else
role = check_user_access_to_service
return redirect_to not_authorised_path unless role

create_or_update_dsi_user(role)
end

Expand All @@ -38,8 +36,8 @@ def create_or_update_dsi_user(role = nil)
session[:dsi_user_session_expiry] = 2.hours.from_now.to_i
end

def check_user_access_to_service
DfESignInApi::GetUserAccessToService.new(
def role
@role ||= DfESignInApi::GetUserAccessToService.new(
org_id: auth.extra.raw_info.organisation.id,
user_id: auth.uid,
).call
Expand Down

0 comments on commit f2f5c75

Please sign in to comment.