fix:change password

This commit is contained in:
k 2020-03-31 10:32:08 +08:00
parent ee80e0f2ff
commit 3db93b4739
2 changed files with 32 additions and 7 deletions

View File

@ -4,6 +4,7 @@ namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\User\UserUpdate;
use App\Http\Requests\User\UserChangePassword;
use Illuminate\Http\Request;
use App\Models\User;
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'));
if (!Helper::multiPasswordVerify(
$user->password_algo,

View 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位数'
];
}
}