UserController::loginRedirect()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controller;
4
5
use Symfony\Component\Routing\Annotation\Route;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
7
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
13
use App\Entity\User\ProductOwner;
14
15
use App\Manager\User\NotificationManager;
16
17
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
18
19
class UserController extends Controller
20
{
21
    /**
22
     * @Route("/login", name="login", methods={"GET", "POST"})
23
     */
24
    public function loginFormAction(AuthenticationUtils $authUtils)
25
    {
26
        return $this->render('front/login.html.twig', [
27
            'error' => $authUtils->getLastAuthenticationError(),
28
            'last_username' => $authUtils->getLastUsername()
29
        ]);
30
    }
31
    
32
    /**
33
     * @Route("/login/redirect", name="login_redirect")
34
     * @Security("has_role('ROLE_USER')")
35
     */
36
    public function loginRedirect()
37
    {
38
        if ($this->getUser() instanceof ProductOwner) {
39
            return $this->redirectToRoute("project_workspace", [
40
                'slug' => $this->getUser()->getProjects()->first()->getSlug()
41
            ]);
42
        }
43
        return $this->redirectToRoute("member_dashboard");
44
    }
45
    
46
    /**
47
     * @Route("/profile", name="my_profile", methods={"GET"})
48
     * @Security("has_role('ROLE_USER')")
49
     */
50
    public function getMyProfile()
51
    {
52
        return $this->render('members/profile.html.twig');
53
    }
54
    
55
    /**
56
     * @Route("/users/me/notifications/read", name="read_notifications", methods={"PATCH"})
57
     * @Security("has_role('ROLE_USER')")
58
     */
59
    public function readNotifications(Request $request, NotificationManager $notificationManager)
60
    {
61
        $notificationManager->read($request->request->get('ids'));
62
        return new Response(null, 204);
63
    }
64
}