SlackController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A connectAction() 0 6 1
A connectCheckAction() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Controller\Oauth2;
12
13
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
14
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
use Symfony\Component\HttpFoundation\RedirectResponse;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Routing\Annotation\Route;
19
20
/**
21
 * @Route("/oauth2/slack", name="oauth2_slack")
22
 */
23
class SlackController extends AbstractController
24
{
25
    /**
26
     * @Route("/connect", name="_connect")
27
     */
28
    public function connectAction(ClientRegistry $clientRegistry): RedirectResponse
29
    {
30
        return $clientRegistry
31
            ->getClient('slack')
32
            ->redirect(['identity.basic', 'identity.email']);
33
    }
34
35
    /**
36
     * @Route("/check", name="_check")
37
     */
38
    public function connectCheckAction(): Response
39
    {
40
        if (!$this->getUser()) {
41
            return new JsonResponse(['status' => false, 'message' => 'User not found!'], JsonResponse::HTTP_UNAUTHORIZED);
42
        }
43
44
        return $this->redirectToRoute('site_page_contact');
45
    }
46
}
47