|
1
|
|
|
<?php namespace Arcanesoft\Auth\Http\Requests\Backend\Profile; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Auth\Bases\FormRequest; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class UpdatePasswordRequest |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanesoft\Auth\Http\Requests\Backend\Profile |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class UpdatePasswordRequest extends FormRequest |
|
12
|
|
|
{ |
|
13
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
14
|
|
|
| Properties |
|
15
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
16
|
|
|
*/ |
|
17
|
|
|
/** |
|
18
|
|
|
* The Validation rules. |
|
19
|
|
|
* |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $rules = [ |
|
23
|
|
|
'old_password' => 'required|min:8|different:password|user_password', |
|
24
|
|
|
'password' => 'required|min:8|different:old_password|confirmed', |
|
25
|
|
|
'password_confirmation' => 'required|min:8', |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var \Arcanesoft\Contracts\Auth\Models\User $user |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $user; |
|
32
|
|
|
|
|
33
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
34
|
|
|
| Main Functions |
|
35
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
36
|
|
|
*/ |
|
37
|
|
|
/** |
|
38
|
|
|
* Determine if the user is authorized to make this request. |
|
39
|
|
|
* |
|
40
|
|
|
* @return bool |
|
41
|
|
|
*/ |
|
42
|
|
|
public function authorize() |
|
43
|
|
|
{ |
|
44
|
|
|
/** @var \Arcanesoft\Contracts\Auth\Models\User $user */ |
|
45
|
|
|
$user = $this->route('user_id'); |
|
46
|
|
|
|
|
47
|
|
|
return $user->id === auth()->user()->id; |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get the validation rules that apply to the request. |
|
52
|
|
|
* |
|
53
|
|
|
* @return array |
|
54
|
|
|
*/ |
|
55
|
|
|
public function rules() |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->rules; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Set custom messages for validator errors. |
|
62
|
|
|
* |
|
63
|
|
|
* @return array |
|
64
|
|
|
*/ |
|
65
|
|
|
public function messages() |
|
66
|
|
|
{ |
|
67
|
|
|
return [ |
|
68
|
|
|
'old_password.different' => 'The old and new passwords must be different.', |
|
69
|
|
|
'password.different' => 'The old and new passwords must be different.', |
|
70
|
|
|
]; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: