Skip to content

Commit 3debbe7

Browse files
committed
Redirect after callback
This functionality makes it possible to redirect to any route of your choice after authentication Signed-off-by: Dieter Coopman <dieter@deltasolutions.be>
1 parent 7d8bf3f commit 3debbe7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MS_CLIENT_ID=
4040
MS_CLIENT_SECRET=
4141
MS_GRAPH_API_VERSION=v1.0
4242
MS_REDIRECT_URL=https://your-url.com/microsoft/callback
43+
MS_REDIRECT_AFTER_CALLBACK_URL=https://your-url.com/dashboard
4344
```
4445

4546
## Connect your account
@@ -75,6 +76,8 @@ please provide this variable with your accessData as value when logging in.
7576
For example: On login, you get your accesData from the database and store it into the session
7677
variable `microsoftgraph-access-data`.
7778

79+
After the callback, the package will redirect you to the url you specified in the `MS_REDIRECT_AFTER_CALLBACK_URL` variable. If this variable is not set, the package will redirect to the root of your application.
80+
7881
## Mail usage
7982

8083
### Configuration

src/Authenticate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function callback()
4646
} else {
4747
$tokenData = Http::asForm()->post('https://login.microsoftonline.com/' . config('services.microsoft.tenant') . '/oauth2/token', $this->getTokenFields(request('code')))->object();
4848
$this->dispatchCallbackReceived($tokenData);
49-
return redirect('/');
49+
return redirect(config('services.microsoft.redirect_after_callback'));
5050
}
5151
}
5252
}

src/MicrosoftgraphServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private function buildConfigs()
4242
'client_id' => env('MS_CLIENT_ID'),
4343
'client_secret' => env('MS_CLIENT_SECRET'),
4444
'redirect' => env('MS_REDIRECT_URL'),
45+
'redirect_after_callback' => env('MS_REDIRECT_AFTER_CALLBACK_URL','/'),
4546
],
4647
], $config));
4748

0 commit comments

Comments
 (0)