Completed
Push — master ( 8927df...f70445 )
by Abdelrahman
02:05
created

Controllers/Frontend/UserSessionsController.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
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Http\Controllers\Frontend;
17
18
use Illuminate\Http\Request;
19
use Rinvex\Fort\Http\Controllers\AuthenticatedController;
20
21
class UserSessionsController extends AuthenticatedController
22
{
23
    /**
24
     * Show the account sessions.
25
     *
26
     * @return \Illuminate\Http\Response
27
     */
28
    public function index()
29
    {
30
        return view('rinvex/fort::frontend/user.sessions');
31
    }
32
33
    /**
34
     * Flush the given session.
35
     *
36
     * @param string|null $token
37
     *
38
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
39
     */
40
    public function flush(Request $request, $token = null)
41
    {
42
        $status = '';
43
44
        if ($token) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $token of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
45
            app('rinvex.fort.persistence')->delete($token);
46
            $status = trans('rinvex/fort::frontend/messages.auth.session.flushed');
47
        } elseif (request()->get('confirm')) {
48
            app('rinvex.fort.persistence')->deleteByUser($request->user($this->getGuard())->id);
49
            $status = trans('rinvex/fort::frontend/messages.auth.session.flushedall');
50
        }
51
52
        return intend([
53
            'back' => true,
54
            'with' => ['rinvex.fort.alert.warning' => $status],
55
        ]);
56
    }
57
}
58