@@ -48,6 +48,7 @@ class LoginController extends Controller {
4848 private const STATE = 'oidc.state ' ;
4949 private const NONCE = 'oidc.nonce ' ;
5050 private const PROVIDERID = 'oidc.providerid ' ;
51+ private const REDIRECTURL = 'oidc.redirecturl ' ;
5152
5253 /** @var ISecureRandom */
5354 private $ random ;
@@ -112,7 +113,7 @@ public function __construct(
112113 * @NoCSRFRequired
113114 * @UseSession
114115 */
115- public function login (int $ providerId ) {
116+ public function login (int $ providerId, string $ redirectUrl = '' ) {
116117 $ this ->logger ->debug ('Initiating login for provider with id: ' . $ providerId );
117118
118119 //TODO: handle exceptions
@@ -125,6 +126,9 @@ public function login(int $providerId) {
125126 $ this ->session ->set (self ::NONCE , $ nonce );
126127
127128 $ this ->session ->set (self ::PROVIDERID , $ providerId );
129+
130+ $ this ->session ->set (self ::REDIRECTURL , $ redirectUrl );
131+
128132 $ this ->session ->close ();
129133
130134 $ data = [
@@ -252,9 +256,12 @@ public function code($state = '', $code = '', $scope = '') {
252256
253257 $ this ->logger ->debug ('Redirecting user ' );
254258
255- // TODO: user proper redirect url
259+ $ redirectUrl = $ this ->session ->get (self ::REDIRECTURL );
260+ if ($ redirectUrl === '' ) {
261+ $ redirectUrl = \OC_Util::getDefaultPageUrl ();
262+ }
256263
257- return new RedirectResponse (\OC_Util:: getDefaultPageUrl () );
264+ return new RedirectResponse ($ redirectUrl );
258265 }
259266
260267 private function obtainDiscovery (string $ url ) {
0 commit comments