/**
  * Overwrite the getLogout function in Illuminate\Foundation\Auth\AuthenticatesUsers;
  */
 public function getLogout()
 {
     \Auth::logout();
     \Session::forget('cart_merge');
     // custom feature
     return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/home');
 }
Beispiel #2
0
 public function redirectPath()
 {
     if (\Auth::user()->isUser('user')) {
         return '/home';
     }
     return '/dashboard';
 }
Beispiel #3
0
 public function authenticate () 
 {
   if (Auth::attempt(['mobile' => $mobile, 'password' => $password])) 
   {
     return redirect()->intended('home');
   }
 }
Beispiel #4
0
 /**
  * Log the user out of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getLogout()
 {
     $user = \Auth::user()->name;
     \Auth::logout();
     \Session::flash('flash_message', $user . ': You have been logged out.');
     return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
 }
 /**
  * Reset the given user's password.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     // print_r($credentials);
     // die;
     $response = $this->passwords->reset($credentials, function ($user, $password) {
         echo "reset password";
         die;
         $user->password = bcrypt($password);
         $user->save();
         $this->auth->login($user);
     });
     switch ($response) {
         case PasswordBroker::PASSWORD_RESET:
             $user = \Auth::user();
             if ($user->email_activated != '1') {
                 $user->email_activated = '1';
                 $user->email_activated_at = new \DateTime();
                 $user->save();
             }
             return redirect($this->redirectPath());
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }
Beispiel #6
0
 /**
  * Override the default getLogout method.
  * After logging out, unset/forget the jwt cookie.
  *
  * @return $this
  */
 public function getLogout()
 {
     //unset the cookie
     JWTService::unsetCookie();
     \Auth::logout();
     return redirect('/');
 }
Beispiel #7
0
 /**
  * Create a new authentication controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     if (\Auth::check()) {
         return redirect('/');
     }
     $this->middleware('guest', ['except' => 'getLogout']);
 }
Beispiel #8
0
 public function postLogin(\App\Http\Requests\LoginUserRequest $request)
 {
     if (\Auth::attempt($request->except('_token'), true)) {
         return redirect()->intended('/');
     }
     return back()->withInput()->with(['message' => 'Wrong email or password']);
 }
 /**
  * Handle a login request to the application.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postLogin(\Illuminate\Http\Request $request)
 {
     if (\App::environment('local')) {
         $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     } else {
         $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required', 'g-recaptcha-response' => 'required|recaptcha']);
     }
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     if (\Auth::attempt($credentials, $request->has('remember'))) {
         return $this->handleUserWasAuthenticated($request, $throttles);
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
 public function login(Request $request)
 {
     //        dd(\Crypt::encrypt('*****@*****.**'));
     try {
         $email = \Crypt::decrypt($request->get('token'));
     } catch (\Exception $e) {
         return abort('403', 'Forbidden');
     }
     $user = User::whereEmail($email)->first();
     if (!$user) {
         return abort('403', 'Forbidden');
     }
     if (!$user->account) {
         $b2bCompany = \DB::connection('mysql-b2b')->table('companies')->where('user_id', '=', $user->id)->first();
         //            $b2bCompany = false;
         $accountName = $b2bCompany ? $b2bCompany->company_name : $user->email;
         $account = new Account();
         $account->ip = $request->getClientIp();
         $account->name = $accountName;
         $account->account_key = str_random(RANDOM_KEY_LENGTH);
         $account->save();
         $user->account_id = $account->id;
         $user->registered = true;
         $user->save();
         $exists = \DB::connection('mysql')->table('users')->whereId($user->id)->count();
         if (!$exists) {
             \DB::connection('mysql')->table('users')->insert(['id' => $user->id, 'account_id' => $user->account_id, 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'deleted_at' => $user->deleted_at, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'phone' => $user->phone, 'username' => $user->username, 'email' => $user->email, 'password' => $user->password, 'confirmation_code' => $user->confirmation_code, 'registered' => $user->registered, 'confirmed' => $user->confirmed, 'notify_sent' => $user->notify_sent, 'notify_viewed' => $user->notify_viewed, 'notify_paid' => $user->notify_paid, 'public_id' => $user->public_id, 'force_pdfjs' => false, 'remember_token' => $user->remember_token, 'news_feed_id' => $user->news_feed_id, 'notify_approved' => $user->notify_approved, 'failed_logins' => $user->failed_logins, 'dark_mode' => $user->dark_mode, 'referral_code' => $user->referral_code]);
         }
     }
     \Auth::loginUsingId($user->id);
     return redirect('/');
 }
Beispiel #11
0
 public function facebookRedirect()
 {
     // Automatically log in existing users
     // or create a new user if necessary.
     SocialAuth::login('facebook', function ($user, $details) {
         $existing_user = User::where('email', $details->email)->first();
         if ($existing_user !== NULL) {
             $existing_user->avatar = $details->avatar;
             $existing_user->save();
             return $existing_user;
             // Tell the package to use this user instead of creating a new one.
         }
         $user->name = $details->full_name;
         $user->avatar = $details->avatar;
         $user->email = $details->email;
         $user->save();
         $roles_allowed = [2];
         $user->syncRoles($roles_allowed);
     });
     // Current user is now available via Auth facade
     $user = Auth::user();
     if ($user->wasRecentlyCreated == TRUE) {
         return redirect('payment')->with('message', 'Update Payment details!');
     }
     return redirect()->intended('/backend/home');
 }
 /**
  * Log the user out of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getLogout()
 {
     $user = Auth::user();
     $user->status = 'unavailable';
     $user->save();
     return $this->logout();
 }
Beispiel #13
0
 public function logout()
 {
     \Auth::logout();
     // logout user
     return \Redirect::to('admin/login');
     //redirect back to login
 }
Beispiel #14
0
 /**
  * Log the user out of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getLogout()
 {
     \Auth::logout();
     \Session::flash('flash_message', 'You are Logged Out.');
     return redirect('/');
     //return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
 }
 public function handleProviderCallback()
 {
     //$user = Socialite::with('facebook')->user();
     //dd($user);
     try {
         $user = Socialite::with('facebook')->user();
     } catch (Exception $e) {
         return redirect('/login/facebook');
     }
     dd($user);
     $authUser = $this->findOrCreateUser($user);
     Auth::login($authUser, true);
     return redirect('/home');
     //        // OAuth Two Providers
     //        $token = $user->token;
     //
     //// OAuth One Providers
     //        $token = $user->token;
     //        $tokenSecret = $user->tokenSecret;
     //
     //// All Providers
     //        $user->getId();
     //        $user->getNickname();
     //        $user->getName();
     //        $user->getEmail();
     //        $user->getAvatar();
     //
 }
Beispiel #16
0
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function authenticate()
 {
     if (Auth::attempt(['username' => $email, 'password' => $password, 'is_enabled' => 1])) {
         // Authentication passed...
         return redirect()->intended('home');
     }
 }
 public function postRegister(Request $request)
 {
     $validator = $this->registrar->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $this->auth->login($this->registrar->create($request->all()));
     $id = DB::getPdo()->lastInsertId();
     $user = \Auth::user();
     if (Input::get('state') === 'company') {
         $user->isCompany = 1;
         $user->save();
         return Redirect('company/project');
     } else {
         if (Input::get('state') === 'student') {
             $user->isStudent = True;
             $user->save();
             return Redirect('profile');
         } else {
             if (Input::get('state') === 'expertise') {
                 $user->isExpertise = True;
                 $user->save();
                 return Redirect('profile');
             }
         }
     }
 }
Beispiel #18
0
 /**
  * Display the specified resource.
  *
  * @return Response
  */
 public function showOptions()
 {
     if (\Auth::check()) {
         return redirect("/home");
     }
     return view("login");
 }
 /**
  *  退出登录
  */
 public function logout()
 {
     if (Auth::check()) {
         Auth::logout();
     }
     return Redirect::to('login');
 }
Beispiel #20
0
 public function authenticate(Request $request)
 {
     if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
         // Authentication passed...
         return redirect()->intended('/');
     }
 }
 public function getLogout()
 {
     \Session::flush();
     \Cache::flush();
     \Auth::logout();
     return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
 }
 /**
  * Create a new authentication controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     if (\Auth::check()) {
         $this->redirectTo = url(\Auth::user()->slug);
     }
     $this->middleware('guest', ['except' => 'logout']);
 }
Beispiel #23
0
 public function getLogout()
 {
     \Auth::logout();
     \Session::flash('flash_message', 'You have been logged out');
     \Session::flash('flash_type', 'alert-info');
     return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
 }
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function authenticate()
 {
     if (Auth::attempt(['usr_email' => $email, 'usr_password' => $password])) {
         // Authentication passed...
         return redirect()->intended('helloworld');
     }
 }
Beispiel #25
0
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function authenticate()
 {
     if (Auth::attempt(['email' => $email, 'password' => $password])) {
         // Authentication passed...
         return redirect()->intended('/dash');
     }
 }
Beispiel #26
0
 public function getRegister()
 {
     if (\Auth::user()) {
         return view('auth.register');
     } else {
         return redirect(url('/'));
     }
 }
 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     return false;
 }
 public function postSecure()
 {
     if (\Auth::check()) {
         return 1;
     } else {
         return 0;
     }
 }
 public function logout(Request $request)
 {
     \Auth::logout();
     if ($request->wantsJson()) {
         return response()->json(['success' => true], 200);
     }
     return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
 }
Beispiel #30
0
 protected function loginUser(Request $request)
 {
     $email = $request['email'];
     $password = $request['password'];
     if (\Auth::attempt(['email' => $email, 'password' => $password])) {
         return redirect('/dashboard');
     }
 }