Completed
Push — master ( a49823...664dd1 )
by Philip
23:56
created

src/Controller/DefaultController.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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()) {
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