@@ -104,13 +104,12 @@ public function boot(IBootContext $context): void {
104104 * This is the automatic redirect exclusively for Nextcloud/Magentacloud clients
105105 * completely skipping consent layer
106106 */
107- private function registerNmcClientFlow (IRequest $ request ,
108- IURLGenerator $ urlGenerator ,
109- ProviderMapper $ providerMapper ,
110- ISession $ session ,
111- ISecureRandom $ random ): void {
112-
113- $ providers = $ this ->getCachedProviders ($ providerMapper );
107+ private function registerNmcClientFlow (IRequest $ request ,
108+ IURLGenerator $ urlGenerator ,
109+ ProviderMapper $ providerMapper ,
110+ ISession $ session ,
111+ ISecureRandom $ random ): void {
112+ $ providers = $ this ->getCachedProviders ($ providerMapper );
114113
115114 // Handle immediate redirect on client first-time login
116115 $ isClientLoginFlow = false ;
@@ -125,33 +124,33 @@ private function registerNmcClientFlow(IRequest $request,
125124 return strtolower ($ p ->getIdentifier ()) === "telekom " ;
126125 }));
127126 if (count ($ tproviders ) == 0 ) {
128- // always show normal login flow as error fallback
129- return ;
130- }
131-
132- $ stateToken = $ random ->generate (
133- 64 ,
134- ISecureRandom::CHAR_LOWER .ISecureRandom::CHAR_UPPER .ISecureRandom::CHAR_DIGITS
135- );
136- $ session ->set ('client.flow.state.token ' , $ stateToken );
127+ // always show normal login flow as error fallback
128+ return ;
129+ }
130+
131+ $ stateToken = $ random ->generate (
132+ 64 ,
133+ ISecureRandom::CHAR_LOWER .ISecureRandom::CHAR_UPPER .ISecureRandom::CHAR_DIGITS
134+ );
135+ $ session ->set ('client.flow.state.token ' , $ stateToken );
137136
138- // call the service to get the params, but suppress the template
139- // compute grant redirect Url to go directly to Telekom login
140- $ redirectUrl = $ urlGenerator ->linkToRoute ('core.ClientFlowLogin.grantPage ' , [
141- 'stateToken ' => $ stateToken ,
142- // grantPage service operation is deriving oauth2 client name (again),
143- // so we simply pass on clientIdentifier or empty string
144- 'clientIdentifier ' => $ request ->getParam ('clientIdentifier ' , '' ),
145- 'direct ' => $ request ->getParam ('direct ' , '0 ' )
146- ]);
147- if ($ redirectUrl === null ) {
148- // always show normal login flow as error fallback
149- return ;
150- }
151-
152- // direct login, consent layer later
137+ // call the service to get the params, but suppress the template
138+ // compute grant redirect Url to go directly to Telekom login
139+ $ redirectUrl = $ urlGenerator ->linkToRoute ('core.ClientFlowLogin.grantPage ' , [
140+ 'stateToken ' => $ stateToken ,
141+ // grantPage service operation is deriving oauth2 client name (again),
142+ // so we simply pass on clientIdentifier or empty string
143+ 'clientIdentifier ' => $ request ->getParam ('clientIdentifier ' , '' ),
144+ 'direct ' => $ request ->getParam ('direct ' , '0 ' )
145+ ]);
146+ if ($ redirectUrl === null ) {
147+ // always show normal login flow as error fallback
148+ return ;
149+ }
150+
151+ // direct login, consent layer later
153152 $ targetUrl = $ urlGenerator ->linkToRoute (self ::APP_ID . '.login.login ' , [
154- 'providerId ' => $ tproviders [0 ]->getId (),
153+ 'providerId ' => $ tproviders [0 ]->getId (),
155154 'redirectUrl ' => $ redirectUrl
156155 ]);
157156 header ('Location: ' . $ targetUrl );
0 commit comments