当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::once方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Auth::once方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::once方法的具体用法?PHP Auth::once怎么用?PHP Auth::once使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Auth的用法示例。


在下文中一共展示了Auth::once方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: verify

 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     return false;
 }
开发者ID:cursosmau,项目名称:laravel-api,代码行数:8,代码来源:Verifier.php

示例2: verify

 public function verify($username, $password)
 {
     $credentials = ['usuario' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->IdUsuario;
     }
     return false;
 }
开发者ID:heitorluz,项目名称:InfologNFe,代码行数:8,代码来源:UsuarioService.php

示例3: authenticate

 /**
  * Authenticate with json response, use for external auth
  *
  * @param Request $request
  *
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function authenticate(Request $request)
 {
     $params = $request->only('email', 'password');
     if (Auth::once($params)) {
         return Auth::user();
     }
     return response(['error' => 'Invalid user.']);
 }
开发者ID:grepollo,项目名称:dkb_readtime,代码行数:15,代码来源:ExternalController.php

示例4: verifyAdmin

 public function verifyAdmin($username, $password)
 {
     $credentials = ['username' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->type == "admin" ? Auth::user()->id : false;
     } else {
         return false;
     }
 }
开发者ID:kidshenlong,项目名称:comic-cloud-lumen,代码行数:9,代码来源:PasswordGrantVerifier.php

示例5: verify

 public function verify($username, $password)
 {
     $telephoneCredentials = ['telephone' => $username, 'password' => $password];
     $usernameCredentials = ['username' => $username, 'password' => $password];
     $emailCredentials = ['email' => $username, 'password' => $password];
     if (Auth::once($telephoneCredentials) || Auth::once($usernameCredentials) || Auth::once($emailCredentials)) {
         return Auth::user()->id;
     }
     return false;
 }
开发者ID:xifat,项目名称:Laravel-OAuth2-Dingo,代码行数:10,代码来源:PasswordGrantVerifier.php

示例6: verify

 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     /*if(Auth::validate($credentials)){
           $user = \CodeProject\Entities\User::where('email',$username)->first();
           
           return $user->id;
       }*/
     return false;
 }
开发者ID:alanrobzureta,项目名称:curso-laravel-angular,代码行数:13,代码来源:Verifier.php

示例7: auth

 public function auth(Request $request)
 {
     $data = $this->validateRequest($request, ['username', 'password'], true);
     $result = Auth::once(['username' => $data->username, 'password' => $data->password]);
     if ($result !== true || !Auth::user()->isDriver()) {
         throw new LoginException("Logging in user: {$data->username}");
     }
     // Generate session key
     $key = Str::random(32);
     $this->cache->put("shuttle.{$this->shuttle->name}.key", $key, 60 * 8);
     $this->cache->put("shuttle.{$this->shuttle->name}.user", Auth::user(), 60 * 8);
     return $this->encryptJson(['key' => $key]);
 }
开发者ID:pasadinhas,项目名称:sirs-project,代码行数:13,代码来源:SecureController.php

示例8: postLogin

 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin()
 {
     $loginData = Binput::only(['email', 'password']);
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         return Redirect::intended('dashboard');
     }
     return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
 }
开发者ID:xiuchanghu,项目名称:Gitamin,代码行数:18,代码来源:AuthController.php

示例9: verify

 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     // Check for FB login
     if ($this->request->has('token_facebook')) {
         $user = $this->userRepo->createUser($this->request->all());
         return $user->id;
     }
     // For normal users
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     return false;
 }
开发者ID:muhammadshakeel,项目名称:laravel-api-boilerplate-oauth,代码行数:14,代码来源:PasswordVerifier.php

示例10: loginPost

 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function loginPost()
 {
     $loginData = Request::only(['login', 'password']);
     // Login with username or email.
     $loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
     $loginData[$loginKey] = array_pull($loginData, 'login');
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         //return Redirect::intended('/')
         return Redirect::home()->withSuccess(trans('gitamin.signin.success'));
     }
     return Redirect::route('auth.login')->withInput(Request::except('password'))->withError(trans('gitamin.signin.invalid'));
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:22,代码来源:AuthController.php

示例11: verify

 public function verify($username, $password)
 {
     $hash = Request::input('hash');
     $credentials = ['username' => $username, 'password' => $password];
     if (presence($hash) && $hash === 'md5') {
         // prehashed, we want to skip the md5 step of OsuHasher
         $user = User::where('username', $username)->first();
         if (password_verify($password, $user->getAuthPassword())) {
             return $user->user_id;
         }
     } else {
         if (Auth::once($credentials)) {
             return Auth::user()->user_id;
         }
     }
     return false;
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:17,代码来源:OAuth2PasswordGrantVerifier.php

示例12: postLogin

 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin()
 {
     $loginData = Binput::only(['email', 'password']);
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // Do we have Two Factor Auth enabled?
         if (Auth::user()->hasTwoFactor) {
             // Temporarily store the user.
             Session::put('2fa_id', Auth::user()->id);
             return Redirect::route('auth.two-factor');
         }
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         return Redirect::intended('dashboard');
     }
     return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
 }
开发者ID:guduchango,项目名称:Cachet,代码行数:24,代码来源:AuthController.php

示例13: login

 /**
  * @param $data
  * @return \Alfredoem\Ragnarok\Soul\RagnarokResponse
  */
 public function login($data)
 {
     if (!key_exists('remember', $data)) {
         $data['remember'] = false;
     }
     // login attempt
     if (Auth::once(['email' => $data['email'], 'password' => $data['password']], $data['remember'])) {
         $auth = Auth::user();
         // Store session user
         $session = SecUserSessions::create(['userId' => $auth->userId, 'sessionCode' => Make::uniqueString(), 'ipAddress' => $data['ipAddress'], 'status' => 1, 'dateIns' => date('Y-m-d'), 'datetimeIns' => date('Y-m-d H:m:s')]);
         $auth->ipAddress = $data['ipAddress'];
         $auth->sessionCode = $session->sessionCode;
         $auth->userSessionId = $session->userSessionId;
         $auth->environment = Session::get('environment');
         // Make ragnarok user
         $this->userRagnarok->make($auth);
         $this->success = true;
     }
     return $this->responseRagnarok->make($this->success, $this->userRagnarok);
 }
开发者ID:alfredoem,项目名称:ragnarok,代码行数:24,代码来源:RagnarokApi.php

示例14: postLogin

 /**
  * Handle a login request to the application.
  *
  * @param  LoginRequest  $request
  * @return Response
  */
 protected function postLogin(Request $request)
 {
     $throttles = $this->isUsingThrottlesLoginsTrait();
     $credentials = $this->getCredentials($request);
     $validator = Validator::make($credentials, ['email' => 'required|email', 'password' => 'required']);
     if ($validator->fails()) {
         if (!$this->api) {
             return redirect(route('login'))->withErrors($validator);
         } else {
             return response()->json(['data' => ['errors' => $validator->errors()->getMessages()]], 400);
         }
     }
     $result = $this->api ? Auth::once($credentials, $request->has('remember')) : Auth::attempt($credentials, $request->has('remember'));
     if (!$result) {
         if (!$this->api) {
             return redirect(route('register'));
         } else {
             return response()->json(['data' => ['message' => 'Error authorization']], 401);
         }
     }
     if (!$this->api) {
         return redirect(route('home'));
     } else {
         $token = Auth::user()->generationToken();
         return response()->json(['data' => ['token' => $token]], 200);
     }
 }
开发者ID:sava90,项目名称:laravel,代码行数:33,代码来源:AuthController.php

示例15: authenticate

 /**
  * @param $username
  * @param $password
  * @return bool or user id
  */
 public function authenticate($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     Log::info("Tentativa de login falhou. Usuário: {$username}, Senha: {$password}");
     return false;
 }
开发者ID:renatovaler,项目名称:code-education,代码行数:14,代码来源:OAuth2Service.php


注:本文中的Illuminate\Support\Facades\Auth::once方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。