mirror of
https://github.com/v2board/v2board.git
synced 2024-11-11 01:59:12 +08:00
30 lines
893 B
PHP
30 lines
893 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Passport;
|
||
|
|
||
|
use App\Http\Requests\Passport\ForgetIndex;
|
||
|
use Illuminate\Http\Request;
|
||
|
use App\Http\Controllers\Controller;
|
||
|
use App\Models\User;
|
||
|
use Illuminate\Support\Facades\Mail;
|
||
|
use Illuminate\Support\Facades\Redis;
|
||
|
|
||
|
class ForgetController extends Controller
|
||
|
{
|
||
|
public function index (ForgetIndex $request) {
|
||
|
$redisKey = 'sendEmailVerify:' . $request->input('email');
|
||
|
if (Redis::get($redisKey) !== $request->input('email_code')) {
|
||
|
abort(500, '邮箱验证码有误');
|
||
|
}
|
||
|
$user = User::where('email', $request->input('email'))->first();
|
||
|
$user->password = password_hash($request->input('password'), PASSWORD_DEFAULT);
|
||
|
if (!$user->save()) {
|
||
|
abort(500, '重置失败');
|
||
|
}
|
||
|
Redis::del($redisKey);
|
||
|
return response([
|
||
|
'data' => true
|
||
|
]);
|
||
|
}
|
||
|
}
|