Completed
Push — master ( 402c8e...a49823 )
by Philip
22:11
created

DefaultController::loggedoutAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Controller;
4
5
use Dontdrinkandroot\GitkiBundle\Controller\BaseController;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Security\Core\Exception\AuthenticationException;
9
10
class DefaultController extends BaseController
11
{
12
    public function indexAction()
13
    {
14
        return $this->redirect($this->generateUrl('ddr_gitki_directory', ['path' => '/', 'action' => 'index']));
15
    }
16
17
    public function loginAction(Request $request)
18
    {
19 View Code Duplication
        if (!$this->isGranted('ROLE_USER')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
            if ($request->hasSession() && $request->isMethodSafe()) {
21
                $referer = $request->headers->get('referer');
22
                if (null !== $referer) {
23
                    $request->getSession()->set('ddr.gitki.manuallogin.targetpath', $referer);
24
                }
25
            }
26
            throw new AuthenticationException();
27
        }
28
29 View Code Duplication
        if ($request->hasSession() && $request->isMethodSafe()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
            $targetPath = $request->getSession()->get('ddr.gitki.manuallogin.targetpath');
31
            $request->getSession()->remove('ddr.gitki.manuallogin.targetpath');
32
            if (null !== $targetPath) {
33
                return $this->redirect($targetPath);
34
            }
35
        }
36
37
        return $this->redirect($this->generateUrl('ddr_gitki_directory', ['path' => '/', 'action' => 'index']));
38
    }
39
40
    /**
41
     * @return Response
42
     */
43
    public function loggedoutAction()
44
    {
45
        return $this->render('DdrGitkiWebBundle:Default:loggedout.html.twig');
46
    }
47
}
48