Passed
Push — feature/application-review-ui ( afbf92 )
by Chris
06:55
created

ResetPasswordController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 24
c 0
b 0
f 0
dl 0
loc 90
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A showResetForm() 0 7 1
A rules() 0 10 1
A validationErrorMessages() 0 3 1
A redirectTo() 0 10 3
A __construct() 0 3 1
1
<?php
2
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
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;
26
27
    /**
28
     * Where to redirect users after resetting their password.
29
     *
30
     * @return string
31
     */
32
    protected function redirectTo()
33
    {
34
        if (WhichPortal::isManagerPortal()) {
35
            $redirectTo = route('manager.home');
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            $redirectTo = /** @scrutinizer ignore-call */ route('manager.home');
Loading history...
36
        } elseif (WhichPortal::isHrPortal()) {
37
            $redirectTo = route('hr_advisor.home');
38
        } else {
39
            $redirectTo = route('home');
40
        }
41
        return $redirectTo;
42
    }
43
44
    /**
45
     * Create a new controller instance.
46
     *
47
     * @return void
48
     */
49
    public function __construct()
50
    {
51
        $this->middleware('guest');
52
    }
53
54
    /**
55
     * Display the password reset view for the given token.
56
     *
57
     * If no token is present, display the link request form.
58
     *
59
     * @param  \Illuminate\Http\Request $request Incoming Request.
60
     * @param  string|null              $token   Validation token.
61
     * @return \Illuminate\Http\Response
62
     */
63
    public function showResetForm(Request $request, $token = null)
64
    {
65
        return view('auth.passwords.reset')->with([
0 ignored issues
show
Bug introduced by
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
        return /** @scrutinizer ignore-call */ view('auth.passwords.reset')->with([
Loading history...
66
            'token' => $token,
67
            'email' => $request->email,
68
            'routes' => $this->auth_routes(),
69
            'reset_password' => Lang::get('common/auth/reset_password'),
70
        ]);
71
    }
72
73
    /**
74
     * OVERRIDE
75
     * Get the password reset validation rules.
76
     *
77
     * @return array
78
     */
79
    protected function rules()
80
    {
81
        return [
82
            'token' => 'required',
83
            'email' => 'required|email',
84
            'password' => [
85
                'required',
86
                'min:8',
87
                new PasswordFormatRule,
88
                'confirmed'
89
            ],
90
        ];
91
    }
92
93
    /**
94
     * OVERRIDE
95
     * Get the password reset validation error messages.
96
     *
97
     * @return array
98
     */
99
    protected function validationErrorMessages()
100
    {
101
        return [];
102
    }
103
}
104