D3strukt0r /
openforum
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Controller; |
||
| 4 | |||
| 5 | use KnpU\OAuth2ClientBundle\Client\ClientRegistry; |
||
| 6 | use KnpU\OAuth2ClientBundle\Security\User\OAuthUser; |
||
| 7 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
||
| 8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
| 9 | use Symfony\Component\Routing\Annotation\Route; |
||
| 10 | use Symfony\Component\Security\Core\User\UserInterface; |
||
| 11 | |||
| 12 | class UserController extends AbstractController |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @Route("/login", name="login") |
||
| 16 | * |
||
| 17 | * @param ClientRegistry $clientRegistry The OAuth2 client registry |
||
| 18 | * |
||
| 19 | * @return RedirectResponse |
||
| 20 | */ |
||
| 21 | public function login(ClientRegistry $clientRegistry) |
||
| 22 | { |
||
| 23 | /** @var OAuthUser $user */ |
||
| 24 | $user = $this->getUser(); |
||
| 25 | if ($user instanceof UserInterface) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 26 | return $this->redirectToRoute('index'); |
||
| 27 | } |
||
| 28 | |||
| 29 | return $clientRegistry |
||
| 30 | ->getClient('generation2') |
||
| 31 | ->redirect(['user:email', 'user:username', 'user:id']) |
||
| 32 | ; |
||
| 33 | } |
||
| 34 | } |
||
| 35 |