AuthController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A logout() 0 4 1
A login() 0 9 1
1
<?php
2
3
/*
4
 * @author  Xavier Chopin <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace App\Controller;
11
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\Routing\Annotation\Route;
14
use phpCAS;
15
16
class AuthController extends AbstractController
17
{
18
    
19
    /**
20
     * Redirects to the CAS authentication page.
21
     *
22
     * @Route("/login", name="login")
23
     * @return \Symfony\Component\HttpFoundation\Response
24
     */
25
    public function login()
26
    {
27
28
        phpCAS::client(CAS_VERSION_2_0, env('CAS_HOST'), intval(env('CAS_PORT')), '');
29
        phpCAS::setNoCasServerValidation();
30
        phpCAS::forceAuthentication();
31
        phpCAS::getUser();
32
33
        return $this->redirectToRoute('home');
34
    }
35
36
    /**
37
     * Logs Out by destroying the CAS Session then redirects to the home page.
38
     *
39
     * @Route("/logout", name="logout")
40
     * @param Request $request
41
     */
42
    public function logout(Request $request)
43
    {
44
        phpCAS::client(CAS_VERSION_2_0, env('CAS_HOST'), intval(env('CAS_PORT')), '');
45
        phpCAS::logoutWithRedirectService('http://' . $request->getBaseUrl());
46
    }
47
}
48