AuthController::logout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
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);
0 ignored issues
show
Bug introduced by
The method flash() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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.');
0 ignored issues
show
Bug introduced by
The method flash() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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));
71
72
        $request->session()->flash($message->type, $message->message);
0 ignored issues
show
Bug introduced by
The method flash() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
73
74
        return redirect('/');
75
    }
76
}
77