当前位置: 首页>>代码示例>>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;未经允许,请勿转载。