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


PHP Guard::login方法代码示例

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


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

示例1: confirm

 /**
  * Confirm account
  *
  * @param $email
  * @param $token
  * @return bool|User
  */
 public function confirm($email, $token)
 {
     $user = $this->userRepo->findByEmailAndToken($email, $token);
     if ($user && $token) {
         $user = $this->userRepo->update($user, ['confirmation_code' => '', 'status' => 1]);
         event(new UserWasConfirmed($user));
         $this->auth->login($user);
         return $user;
     }
     return false;
 }
开发者ID:vjaykoogu,项目名称:smile-media-laravel,代码行数:18,代码来源:UserService.php

示例2: registration

 /**
  * @param Requests\RegistrationFormRequest $request
  *
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function registration(Requests\RegistrationFormRequest $request)
 {
     $data = $request->only('username', 'email', 'password');
     $data['password'] = Hash::make($data['password']);
     $user = new User($data);
     if ($user->save()) {
         $this->auth->login($user);
         return redirect('chat');
     } else {
         return redirect('/')->withErrors(['username' => 'Oops... Something wrong is happened. Try again.'], $request->getErrorBag());
     }
 }
开发者ID:viktory,项目名称:chat,代码行数:17,代码来源:UsersController.php

示例3: callback

 /**
  * Attempts to authenticate the user.
  *
  * @param \App\Models\User\User  $user
  * @param \Illuminate\Auth\Guard $auth
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function callback(User $user, Guard $auth)
 {
     try {
         $payload = $this->socialite->user();
     } catch (Exception $e) {
         $this->flash('Failed to sign in via GitHub, did you decline?', Controller::FLASH_ERROR);
         return redirect()->route('get::front.home');
     }
     try {
         $response = app('GuzzleHttp\\Client')->get('https://api.github.com/user/emails?access_token=' . $payload->token, ['headers' => ['Accept' => 'application/vnd.github.v3+json']]);
         $emails = $response->json();
     } catch (Exception $e) {
         $this->flash('Failed to sign in via GitHub, is your GitHub account verified?', Controller::FLASH_ERROR);
         return redirect()->route('get::front.home');
     }
     $email = array_filter($emails, function ($email) {
         return $email['primary'];
     });
     if (count($email) === 0) {
         $this->flash('Failed to sign in via GitHub, is your GitHub account verified?', Controller::FLASH_ERROR);
         return redirect()->route('get::front.home');
     }
     $email = array_get(array_values($email)[0], 'email');
     $user = $user->firstOrCreate(['uid' => $payload->id]);
     $user->update(['token' => $payload->token, 'email' => $email, 'nickname' => $payload->nickname, 'name' => $payload->nickname]);
     $auth->login($user, true);
     return redirect()->intended('/home');
 }
开发者ID:bigbitecreative,项目名称:paddle,代码行数:36,代码来源:OAuthController.php

示例4: execute

 /**
  * @param boolean $hasCode
  * @param AuthenticateUserListener $listener
  * @param $type
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function execute($hasCode, AuthenticateUserListener $listener, $type)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst();
     }
     $linkedInData = $this->getLinkedinUser();
     $user = $this->users->findOrCreate($linkedInData, $type);
     $this->auth->login($user, true);
     $user->authType = 'linkedin';
     $user->save();
     if (is_null($user->profile)) {
         $name = explode(' ', $linkedInData->name);
         $profile = new Profile(['first_name' => head($name), 'last_name' => last($name)]);
         $user->profile()->save($profile);
     }
     return $listener->userHasLoggedIn($user);
 }
开发者ID:katzumi,项目名称:talent4startups,代码行数:23,代码来源:AuthenticateUser.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request\RegisterUserRequest $request, Guard $auth)
 {
     //
     $input = $request->only('email', 'password', 'name');
     $input['password'] = bcrypt($input['password']);
     $user = User::create($input);
     $auth->login($user);
     return redirect('/');
 }
开发者ID:ememhr,项目名称:laravel_test_app,代码行数:15,代码来源:RegisterController.php

示例6: loginViaOAuth

 /**
  * @param SocialiteUser $oauthUserData
  * @param string        $provider
  *
  * @return bool
  */
 public function loginViaOAuth(SocialiteUser $oauthUserData, $provider)
 {
     /** @var UserOAuth $owningOAuthAccount */
     if ($owningOAuthAccount = UserOAuth::whereRemoteProvider($provider)->whereRemoteId($oauthUserData->id)->first()) {
         $ownerAccount = $owningOAuthAccount->owner;
         $this->auth->login($ownerAccount, true);
         \Event::fire(new LoggedIn($ownerAccount, $provider));
         return true;
     }
     return !$this->registerViaOAuth($oauthUserData, $provider) ? false : true;
 }
开发者ID:AudithSoftworks,项目名称:Basis-API,代码行数:17,代码来源:Registrar.php

示例7: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @param Guard $auth
  * @return Response
  */
 public function handleProviderCallback(Guard $auth)
 {
     $userData = Socialite::driver('vkontakte')->user();
     $userData->provider = "vkontakte";
     $userData->name = $userData->name ?: $userData->nickname;
     $userData->email = $userData->email ?: '';
     $userData->avatar = $userData->avatar ?: '';
     $user = User::findByUserNameOrCreate($userData);
     $auth->login($user, true);
     Flash::success("Выполнен вход через ВКонтакте");
     return redirect('/');
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:18,代码来源:VkontakteAuthController.php

示例8: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @param Guard $auth
  * @return Response
  */
 public function handleProviderCallback(Guard $auth)
 {
     $userData = Socialite::driver('yandex')->user();
     $userData->provider = "yandex";
     $userData->name = $userData->name ?: $userData->user['display_name'];
     $userData->email = $userData->email ?: $userData->user['default_email'];
     $userData->avatar = $userData->avatar ?: "http://avatars.mds.yandex.net/get-yapic/" . $userData->user['default_avatar_id'] . "/islands-50";
     $user = User::findByUserNameOrCreate($userData);
     $auth->login($user, true);
     Flash::success("Выполнен вход через Яндекс");
     return redirect('/');
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:18,代码来源:YandexAuthController.php

示例9: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @param Guard $auth
  * @param Registrar $registrar
  * @return Response
  */
 public function handleProviderCallback(Guard $auth, Registrar $registrar)
 {
     $user = Socialite::driver('facebook')->user();
     $details = array();
     $found_user = User::findByEmailOrFail($user->getEmail());
     if ($found_user) {
         $auth->loginUsingId($found_user->id);
         return redirect()->intended('/home');
     } else {
         $details['name'] = $user->getName();
         $details['email'] = $user->getEmail();
         $details['user_type'] = 'normal';
         $details['mobile_no'] = '';
         $details['password'] = bcrypt(str_random(8));
         $auth->login($registrar->create($details));
         Session::flash('status', 'You have successfully logged in via Facebook.');
         return redirect()->intended('/home');
     }
     return 'Success';
 }
开发者ID:sahilgoyal786,项目名称:cashback-laravel,代码行数:27,代码来源:FacebookAuthController.php

示例10: login

 /**
  * Log a user into the application.
  *
  * @param \Illuminate\Contracts\Auth\Authenticatable $user
  * @param bool $remember
  * @return void 
  * @static 
  */
 public static function login($user, $remember = false)
 {
     \Illuminate\Auth\Guard::login($user, $remember);
 }
开发者ID:satriashp,项目名称:tour,代码行数:12,代码来源:_ide_helper.php

示例11: getLoginWithGithub

 /**
  * Handle Github login.
  *
  * @param \App\Facades\Github    $github
  * @param \Illuminate\Auth\Guard $auth
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getLoginWithGithub(Github $github, Guard $auth)
 {
     if (!$this->request->has('state')) {
         session()->keep(['url']);
         Config::set('services.github.redirect', URL::full());
         return Socialite::driver('github')->redirect();
     } else {
         try {
             $user = $github->register(Socialite::driver('github')->user());
             $auth->login($user);
             if (session()->get('password_required')) {
                 return $this->redirectRoute('user.settings', [], ['update_password' => true]);
             }
             return $this->redirectIntended(route('user.index'));
         } catch (GithubEmailNotVerifiedException $e) {
             return $this->redirectRoute('auth.register', ['github_email_not_verified' => true]);
         }
     }
 }
开发者ID:qloog,项目名称:site,代码行数:27,代码来源:AuthController.php

示例12: switchToUser

 public function switchToUser($user, $remember = false)
 {
     $this->auth->login($user, $remember);
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:4,代码来源:UserManager.php


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