public function sendResetLink($data) { $userDao = new UsersDao(); $user = $userDao->getUserByParam('email', $data['email']); if ($user->isEmpty()) { throw new \Exception("Email is not registered"); } $user = $user[0]; $hash = md5(time() . $user->id . 'ASKLD128fjsdfksfuewqekjsu'); $user->reset_hash = $hash; $user->save(); // send mail $mailService = new MailService(); $passwordArray = array(); $passwordArray['to'] = $user->email; $passwordArray['user_object'] = $user; $webClient = env('WEB_CLIENT'); $passwordArray['reset_link'] = $webClient . "#/resetpassword/" . $hash; $passwordArray['user_object'] = $user; $sent = $mailService->resetPasswordMail($passwordArray); if ($sent) { return "Succesfully sent"; } else { return "Error sending mail"; } }
function forgotPassword(RequestFacade $request) { $usersDao = new UsersDao(); $inputArray = RequestFacade::all(); $inputArray['user_object'] = $this->getLoggedInUser(); $user = $usersDao->changePassword(); return $this->jsonResponse($user); }
/** * Obtain the user information from Facebook * * @return Response */ public function handlefbCallback() { $user = Socialite::driver('facebook')->user(); $data = array(); $data['first_name'] = $user->getName(); $data['social_site_id'] = $user->getId(); $data['email'] = $user->getEmail(); $usersDaoObj = new UsersDao(); $user = $usersDaoObj->authSocialLogin($data); $token = JWTAuth::fromUser($user); //$env = \App::environment(); return redirect()->away(env('WEB_CLIENT') . "auth-token/" . $token); }