public function reset($data, $token) { $pr = $this->password_resetsRepository->getByToken($token); if ($pr == NULL) { return ['errorMsg' => 'Bad request.']; } $result = $this->userService->vaildUserDataFormat($data, ['password', 'password_check']); if ($result !== true) { return $result; } try { \DB::beginTransaction(); $user = User::where('email', $pr->email)->first(); $user->passwd = $this->userService->toPasswordFormat($data['password']); $user->save(); $pr->delete(); \DB::commit(); } catch (\Exception $e) { \DB::rollBack(); return ['errorMsg' => 'Someting wrong, please try again later.']; } return true; }
public function userActive($thecode) { $user = User::where('thecode', $thecode)->first(); if ($user == NULL || $user->auth != 0) { return false; } $user->auth = 1; $user->save(); Auth::login($user); return true; }