Completed
Push — master ( 000aae...3730ff )
by Karl
17s
created

AuthController::logout()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php namespace JobApis\JobsToMail\Http\Controllers;
2
3
use Illuminate\Foundation\Bus\DispatchesJobs;
4
use Illuminate\Http\Request;
5
use Illuminate\Routing\Controller as BaseController;
6
use Illuminate\Foundation\Validation\ValidatesRequests;
7
use JobApis\JobsToMail\Http\Requests\LoginUser;
8
use JobApis\JobsToMail\Jobs\Auth\LoginUserWithToken;
9
use JobApis\JobsToMail\Jobs\Auth\SendLoginMessage;
10
11
class AuthController extends BaseController
12
{
13
    use DispatchesJobs, ValidatesRequests;
14
15
    /**
16
     * View login form.
17
     */
18
    public function viewLogin(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        return view('auth.login');
21
    }
22
23
    /**
24
     * View token confirmation form.
25
     */
26
    public function viewConfirm()
27
    {
28
        return view('auth.confirm');
29
    }
30
31
    /**
32
     * Send user a login token
33
     */
34
    public function login(LoginUser $request)
35
    {
36
        $email = $request->only('email')['email'];
37
38
        $message = $this->dispatchNow(new SendLoginMessage($email));
39
40
        $request->session()->flash($message->type, $message->message);
41
42
        return redirect('/confirm');
43
    }
44
45
    /**
46
     * Log out
47
     */
48
    public function logout(Request $request)
49
    {
50
        $request->session()->invalidate();
51
52
        $request->session()->flash('alert-success', 'You have been successfully logged out.');
53
54
        return redirect('/');
55
    }
56
57
    /**
58
     * Forward posts on to confirm endpoint with token
59
     */
60
    public function postConfirm(Request $request)
61
    {
62
        return $this->confirm($request, $request->only('token')['token']);
63
    }
64
65
    /**
66
     * Login a user via token
67
     */
68
    public function confirm(Request $request, $token)
69
    {
70
        $message = $this->dispatchNow(new LoginUserWithToken($token, $request));
0 ignored issues
show
Unused Code introduced by
The call to LoginUserWithToken::__construct() has too many arguments starting with $request.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
71
72
        $request->session()->flash($message->type, $message->message);
73
74
        return redirect('/');
75
    }
76
}
77