@@ -48,6 +48,7 @@ class LoginController extends Controller {
48
48
private const STATE = 'oidc.state ' ;
49
49
private const NONCE = 'oidc.nonce ' ;
50
50
private const PROVIDERID = 'oidc.providerid ' ;
51
+ private const REDIRECTURL = 'oidc.redirecturl ' ;
51
52
52
53
/** @var ISecureRandom */
53
54
private $ random ;
@@ -112,7 +113,7 @@ public function __construct(
112
113
* @NoCSRFRequired
113
114
* @UseSession
114
115
*/
115
- public function login (int $ providerId ) {
116
+ public function login (int $ providerId, string $ redirectUrl = '' ) {
116
117
$ this ->logger ->debug ('Initiating login for provider with id: ' . $ providerId );
117
118
118
119
//TODO: handle exceptions
@@ -125,6 +126,9 @@ public function login(int $providerId) {
125
126
$ this ->session ->set (self ::NONCE , $ nonce );
126
127
127
128
$ this ->session ->set (self ::PROVIDERID , $ providerId );
129
+
130
+ $ this ->session ->set (self ::REDIRECTURL , $ redirectUrl );
131
+
128
132
$ this ->session ->close ();
129
133
130
134
$ data = [
@@ -252,9 +256,12 @@ public function code($state = '', $code = '', $scope = '') {
252
256
253
257
$ this ->logger ->debug ('Redirecting user ' );
254
258
255
- // TODO: user proper redirect url
259
+ $ redirectUrl = $ this ->session ->get (self ::REDIRECTURL );
260
+ if ($ redirectUrl === '' ) {
261
+ $ redirectUrl = \OC_Util::getDefaultPageUrl ();
262
+ }
256
263
257
- return new RedirectResponse (\OC_Util:: getDefaultPageUrl () );
264
+ return new RedirectResponse ($ redirectUrl );
258
265
}
259
266
260
267
private function obtainDiscovery (string $ url ) {
0 commit comments