Skip to content

Commit

Permalink
Merge pull request #492 from canyongbs/feature/ADVAPP-216-calendar-oa…
Browse files Browse the repository at this point in the history
…uth-account-select

[ADVAPP-216]: Adjust Meeting Center calendar oAuth flow to require you select what account to use
  • Loading branch information
Orrison authored Feb 1, 2024
2 parents 933e4e2 + 30fc21d commit e5ae2f4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app-modules/authorization/src/Enums/SocialiteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function config(): Config
'azure_calendar' => new Config(
key: $azureCalendarSettings->client_id,
secret: $azureCalendarSettings->client_secret,
callbackUri: route('socialite.callback', ['provider' => 'azure_calendar']),
callbackUri: route('calendar.outlook.callback'),
additionalProviderConfig: ['tenant' => $azureCalendarSettings->tenant_id ?? 'common']
),
'google' => new Config(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ public function redirect(SocialiteProvider $provider, Request $request)

auth()->guard('web')->logout();

return $provider->driver()
->setConfig($provider->config())
->redirect();
$driver = $provider->driver()
->setConfig($provider->config());

if (in_array($provider, [SocialiteProvider::Azure, SocialiteProvider::Google])) {
$driver->with(['prompt' => 'select_account']);
}

return $driver->redirect();
}

public function callback(SocialiteProvider $provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ public function login(Request $request): RedirectResponse
{
$client = GoogleCalendarManager::client();

return redirect()->away($client->createAuthUrl());
return redirect()->away(
$client->createAuthUrl(
queryParams: [
'prompt' => 'select_account',
]
)
);
}

public function callback(Request $request): RedirectResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function login(Request $request): RedirectResponse
return $driver
->setConfig(SocialiteProvider::AzureCalendar->config())
->scopes(['Calendars.ReadWrite', 'User.Read', 'offline_access'])
->with(['prompt' => 'select_account'])
->redirect();
}

Expand Down

0 comments on commit e5ae2f4

Please sign in to comment.