AuthController::logout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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