Showing
1 changed file
with
12 additions
and
16 deletions
| ... | @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; | ... | @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; |
| 6 | use App\Models\User; | 6 | use App\Models\User; |
| 7 | use App\Models\UserProfile; | 7 | use App\Models\UserProfile; |
| 8 | use Illuminate\Http\Request; | 8 | use Illuminate\Http\Request; |
| 9 | -use Illuminate\Support\Facades\DB; | ||
| 10 | use Illuminate\Support\Facades\Hash; | 9 | use Illuminate\Support\Facades\Hash; |
| 11 | use Illuminate\Support\Facades\Validator; | 10 | use Illuminate\Support\Facades\Validator; |
| 12 | use Jiannei\Response\Laravel\Support\Facades\Response; | 11 | use Jiannei\Response\Laravel\Support\Facades\Response; |
| ... | @@ -219,26 +218,23 @@ class AuthController extends Controller | ... | @@ -219,26 +218,23 @@ class AuthController extends Controller |
| 219 | return Response::fail('', 500, $validator->errors()); | 218 | return Response::fail('', 500, $validator->errors()); |
| 220 | } | 219 | } |
| 221 | 220 | ||
| 222 | - try { | 221 | + $redis = Redis::connection(); |
| 223 | - $redis = Redis::connection(); | ||
| 224 | 222 | ||
| 225 | - if ($request->verify_code != '123123') { | 223 | + if ($request->verify_code != '123123') { |
| 226 | - if ($redis->get($request->email) !== $request->verify_code) { | 224 | + if ($redis->get($request->email) !== $request->verify_code) { |
| 227 | - return Response::fail('verify code failed', 500); | 225 | + return Response::fail('verify code failed', 500); |
| 228 | - } | ||
| 229 | } | 226 | } |
| 227 | + } | ||
| 230 | 228 | ||
| 231 | - $data = $validator->validated(); | 229 | + $data = $validator->validated(); |
| 232 | - | 230 | + $user = User::query()->where("email", "=", $data["email"])->first(); |
| 233 | - DB::transaction(function () use ($data) { | ||
| 234 | - $user = User::query()->where("email", "=", $data["email"])->first(); | ||
| 235 | - | ||
| 236 | - $user->password = bcrypt($data['password']); | ||
| 237 | 231 | ||
| 238 | - $user->save(); | 232 | + if (!$user) return Response::fail("查无此人"); |
| 239 | - }); | ||
| 240 | 233 | ||
| 241 | - return Response::success("","The new password establishes the success. "); | 234 | + try { |
| 235 | + $user->password = bcrypt($data['password']); | ||
| 236 | + $user->save(); | ||
| 237 | + return Response::success([],"The new password establishes the success. "); | ||
| 242 | } catch (\Exception $exception) { | 238 | } catch (\Exception $exception) { |
| 243 | return Response::fail('Failed to set the new password.', 500, $exception->getMessage()); | 239 | return Response::fail('Failed to set the new password.', 500, $exception->getMessage()); |
| 244 | } | 240 | } | ... | ... |
-
Please register or login to post a comment