mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
Merge pull request #149 from SquidFerry/hotfix/password
fix:change password
This commit is contained in:
commit
b2c33cd31b
@ -4,6 +4,7 @@ namespace App\Http\Controllers\User;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\User\UserUpdate;
|
use App\Http\Requests\User\UserUpdate;
|
||||||
|
use App\Http\Requests\User\UserChangePassword;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
@ -23,14 +24,8 @@ class UserController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changePassword(Request $request)
|
public function changePassword(UserChangePassword $request)
|
||||||
{
|
{
|
||||||
if (empty($request->input('old_password'))) {
|
|
||||||
abort(500, '旧密码不能为空');
|
|
||||||
}
|
|
||||||
if (empty($request->input('new_password'))) {
|
|
||||||
abort(500, '新密码不能为空');
|
|
||||||
}
|
|
||||||
$user = User::find($request->session()->get('id'));
|
$user = User::find($request->session()->get('id'));
|
||||||
if (!Helper::multiPasswordVerify(
|
if (!Helper::multiPasswordVerify(
|
||||||
$user->password_algo,
|
$user->password_algo,
|
||||||
|
30
app/Http/Requests/User/UserChangePassword.php
Normal file
30
app/Http/Requests/User/UserChangePassword.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\User;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UserChangePassword extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'old_password' => 'required',
|
||||||
|
'new_password' => 'required|min:8'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'old_password.required' => '旧密码不能为空',
|
||||||
|
'new_password.required' => '新密码不能为空',
|
||||||
|
'new_password.min' => '密码必须大于8位数'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user