|
9 | 9 | use MediaWiki\OAuthClient\Client; |
10 | 10 | use MediaWiki\OAuthClient\ClientConfig; |
11 | 11 | use MediaWiki\OAuthClient\Consumer; |
12 | | -use MediaWiki\OAuthClient\Exception; |
| 12 | +use MediaWiki\OAuthClient\Exception as OAuthException; |
13 | 13 | use MediaWiki\OAuthClient\Token; |
14 | 14 | use OpenApi\Attributes as OA; |
15 | 15 | use Symfony\Component\HttpFoundation\JsonResponse; |
@@ -58,7 +58,7 @@ public function loginAction( |
58 | 58 | try { |
59 | 59 | [ $next, $token ] = $this->getOauthClient( $request, $projectRepo, $urlGenerator, $centralAuthProject ) |
60 | 60 | ->initiate(); |
61 | | - } catch ( Exception $oauthException ) { |
| 61 | + } catch ( OAuthException $oauthException ) { |
62 | 62 | $this->addFlashMessage( 'notice', 'error-login' ); |
63 | 63 | return $this->redirectToRoute( 'homepage' ); |
64 | 64 | } |
@@ -95,19 +95,24 @@ public function oauthCallbackAction( |
95 | 95 | return $this->redirectToRoute( 'homepage' ); |
96 | 96 | } |
97 | 97 |
|
98 | | - $verifier = $request->get( 'oauth_verifier' ); |
99 | | - $accessToken = $client->complete( $token, $verifier ); |
| 98 | + try { |
| 99 | + $verifier = $request->get( 'oauth_verifier' ); |
| 100 | + $accessToken = $client->complete( $token, $verifier ); |
100 | 101 |
|
101 | | - // Store access token, and remove request token. |
102 | | - $session->set( 'oauth_access_token', $accessToken ); |
103 | | - $session->remove( 'oauth_request_token' ); |
| 102 | + // Store access token, and remove request token. |
| 103 | + $session->set( 'oauth_access_token', $accessToken ); |
| 104 | + $session->remove( 'oauth_request_token' ); |
104 | 105 |
|
105 | | - // Store user identity. |
106 | | - $ident = $client->identify( $accessToken ); |
107 | | - $session->set( 'logged_in_user', $ident ); |
| 106 | + // Store user identity. |
| 107 | + $ident = $client->identify( $accessToken ); |
| 108 | + $session->set( 'logged_in_user', $ident ); |
108 | 109 |
|
109 | | - // Store reference to the client. |
110 | | - $session->set( 'oauth_client', $this->oauthClient ); |
| 110 | + // Store reference to the client. |
| 111 | + $session->set( 'oauth_client', $this->oauthClient ); |
| 112 | + } catch ( OAuthException $e ) { |
| 113 | + $this->addFlashMessage( 'notice', 'error-login' ); |
| 114 | + // Redirect below |
| 115 | + } |
111 | 116 |
|
112 | 117 | // Redirect to callback, if given. |
113 | 118 | if ( $request->query->get( 'redirect' ) ) { |
|
0 commit comments