Passed
Push — emailfix ( 0d6707...7fc2cb )
by Tristan
10:42
created

ResetPasswordController::credentials()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Auth\AuthController;
6
use Illuminate\Foundation\Auth\ResetsPasswords;
7
use Illuminate\Http\Request;
8
use Facades\App\Services\WhichPortal;
9
use App\Services\Validation\Rules\PasswordFormatRule;
10
use Illuminate\Support\Facades\Lang;
11
12
class ResetPasswordController extends AuthController
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ResetPasswordController
Loading history...
13
{
14
    /*
15
    |--------------------------------------------------------------------------
16
    | Password Reset Controller
17
    |--------------------------------------------------------------------------
18
    |
19
    | This controller is responsible for handling password reset requests
20
    | and uses a simple trait to include this behavior. You're free to
21
    | explore this trait and override any methods you wish to tweak.
22
    |
23
    */
24
25
    use ResetsPasswords;
0 ignored issues
show
introduced by
The trait Illuminate\Foundation\Auth\ResetsPasswords requires some properties which are not provided by App\Http\Controllers\Auth\ResetPasswordController: $email, $redirectTo
Loading history...
26
27
    /**
28
     * Where to redirect users after resetting their password.
29
     *
30
     * @var string
31
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
32
    protected function redirectTo()
33
    {
34
        $redirectTo = WhichPortal::isManagerPortal() ? route('manager.home') : route('home');
35
        return $redirectTo;
36
    }
37
38
    /**
39
     * Create a new controller instance.
40
     *
41
     * @return void
42
     */
43
    public function __construct()
44
    {
45
        $this->middleware('guest');
46
    }
47
48
    /**
49
     * Display the password reset view for the given token.
50
     *
51
     * If no token is present, display the link request form.
52
     *
53
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
54
     * @param  string|null  $token
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 14 spaces after parameter type; 2 found
Loading history...
55
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
56
     */
57
    public function showResetForm(Request $request, $token = null)
58
    {
59
        return view('auth.passwords.reset')->with([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
60
            'token' => $token,
61
            'email' => strtolower($request->email),
62
            'routes' => $this->auth_routes(),
63
            'reset_password_template' => Lang::get('common/auth/reset_password'),
64
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
65
    }
66
67
    /**
68
     * OVERRIDE
69
     * Get the password reset validation rules.
70
     *
71
     * @return array
72
     */
73
    protected function rules()
74
    {
75
        return [
76
            'token' => 'required',
77
            'email' => 'required|email',
78
            'password' => [
79
                'required',
80
                'min:8',
81
                new PasswordFormatRule,
82
                'confirmed'
83
            ],
84
        ];
85
    }
86
87
    /**
88
     * OVERRIDE
89
     * Get the password reset validation error messages.
90
     *
91
     * @return array
92
     */
93
    protected function validationErrorMessages()
94
    {
95
        return [];
96
    }
97
98
    /**
99
     * OVERRIDE
100
     * Get the password reset credentials from the request, with case insensitive email
101
     *
102
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
103
     * @return array
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
104
     */
105
    protected function credentials(Request $request)
106
    {
107
        $credentials = $request->only(
108
            'email',
109
            'password',
110
            'password_confirmation',
111
            'token'
112
        );
113
        if (isset($credentials['email'])) {
114
            $credentials['email'] = strtolower($credentials['email']);
115
        }
116
        return $credentials;
117
    }
118
}
119