當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Auth::user方法代碼示例

本文整理匯總了PHP中App\Http\Controllers\Auth\Auth::user方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::user方法的具體用法?PHP Auth::user怎麽用?PHP Auth::user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Http\Controllers\Auth\Auth的用法示例。


在下文中一共展示了Auth::user方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: login

 public function login()
 {
     //echo "Came to validation part>>>!";
     if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     }
 }
開發者ID:udayrockstar,項目名稱:phonebook,代碼行數:9,代碼來源:AuthController.php

示例2: __construct

 /**
  * 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']);
 }
開發者ID:sarker-zakee,項目名稱:poststatus,代碼行數:12,代碼來源:AuthController.php

示例3: getLogout

 /**
  * 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();
 }
開發者ID:nicholas-ooi,項目名稱:rocketjobs,代碼行數:12,代碼來源:AuthController.php

示例4: facebookRedirect

 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');
 }
開發者ID:evolvaHQ,項目名稱:uwanja,代碼行數:26,代碼來源:AuthController.php

示例5: postRegister

 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');
             }
         }
     }
 }
開發者ID:michaelotto126,項目名稱:shokes,代碼行數:27,代碼來源:AuthController.php

示例6: getLogout

 /**
  * 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 : '/');
 }
開發者ID:dmorgorg,項目名稱:photos,代碼行數:12,代碼來源:AuthController.php

示例7: redirectPath

 public function redirectPath()
 {
     if (\Auth::user()->isUser('user')) {
         return '/home';
     }
     return '/dashboard';
 }
開發者ID:mauhftw,項目名稱:mizustats,代碼行數:7,代碼來源:AuthController.php

示例8: postReset

 /**
  * 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)]);
     }
 }
開發者ID:prathyushasahusoft,項目名稱:Angular-Scripts,代碼行數:32,代碼來源:PasswordController.php

示例9: getRegister

 public function getRegister()
 {
     if (\Auth::user()) {
         return view('auth.register');
     } else {
         return redirect(url('/'));
     }
 }
開發者ID:Qeenslet,項目名稱:wireworks,代碼行數:8,代碼來源:AuthController.php

示例10: redirectPath

 public function redirectPath()
 {
     // Logic that determines where to send the user
     if (\Auth::user()->type == 'admin') {
         return '/admin';
     }
     return '/dashboard';
 }
開發者ID:burflip,項目名稱:ddsi,代碼行數:8,代碼來源:AuthController.php

示例11: verify

 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     return false;
 }
開發者ID:angelobiscola,項目名稱:lv5-Oauth-configured,代碼行數:8,代碼來源:AuthController.php

示例12: postIndex

 public function postIndex(Request $req)
 {
     $username = \Auth::user()->username;
     if (\Auth::attempt(['username' => $username, 'password' => $req->password])) {
         $req->session()->forget('lock');
         return redirect('/');
     }
     return redirect()->back()->withErr('* Kata sandi tidak cocok!');
 }
開發者ID:pedangkayu,項目名稱:rsos-git,代碼行數:9,代碼來源:LockScreenController.php

示例13: getUser

 public function getUser()
 {
     $responseData = \Auth::user()->toArray();
     $responseData['pingBaseUrl'] = \App\Ping::baseUrl();
     $responseData['avatar'] = \Gravatar::get($responseData['email']);
     unset($responseData['id']);
     unset($responseData['updated_at']);
     return response($responseData, 200);
 }
開發者ID:vestd,項目名稱:ProcessMonitor,代碼行數:9,代碼來源:AuthController.php

示例14: handleUserWasAuthenticated

 protected function handleUserWasAuthenticated(Request $request, $throttles)
 {
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     if (method_exists($this, 'authenticated')) {
         return $this->authenticated($request, Auth::user());
     }
     return redirect()->intended($this->redirectPath());
 }
開發者ID:TIunlam,項目名稱:proyek,代碼行數:10,代碼來源:AuthController.php

示例15: postLogin

 public function postLogin(Request $request)
 {
     $auth = \Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')]);
     if ($auth) {
         \Session::set('user', \Auth::user());
         return redirect("/home");
     } else {
         return redirect("/");
     }
 }
開發者ID:progyny-joe,項目名稱:claimsbybatch,代碼行數:10,代碼來源:AuthController.php


注:本文中的App\Http\Controllers\Auth\Auth::user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。