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


PHP Auth::login方法代码示例

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


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

示例1: callback

 /**
  * Callback action that should be called by auth0, logs the user in
  */
 public function callback()
 {
     // Get a handle of the Auth0 service (we don't know if it has an alias)
     $service = \App::make('auth0');
     // Try to get the user information
     $profile = $service->getUser();
     // Get the user related to the profile
     $auth0User = $this->userRepository->getUserByUserInfo($profile);
     if ($auth0User) {
         if (!str_contains($auth0User->name, '@')) {
             $name = $auth0User->name;
         } else {
             $name = $auth0User->nickname;
         }
         // If we have a user, we are going to log him in, but if
         // there is an onLogin defined we need to allow the Laravel developer
         // to implement the user as he wants an also let him store it.
         $flight = User::firstOrCreate(['github_id' => $auth0User->user_id, 'email' => $auth0User->email, 'picture' => $auth0User->picture, 'name' => $name]);
         if ($service->hasOnLogin()) {
             $user = $service->callOnLogin($auth0User);
         } else {
             // If not, the user will be fine
             $user = $auth0User;
         }
         \Auth::login($user);
     }
     return \Redirect::intended('/');
 }
开发者ID:sgf-web-devs,项目名称:sgf-winner,代码行数:31,代码来源:Auth0Controller.php

示例2: login

 public function login($redirect_path = null)
 {
     $redirect = '/';
     if ($redirect_path) {
         $redirect .= $redirect_path;
     }
     $user = null;
     try {
         $user = Socialize::with('facebook')->user();
     } catch (ClientException $e) {
         return $this->redirectToFacebook($redirect_path);
     } catch (InvalidStateException $e) {
         dd('stop');
     }
     $db_user = User::where('fb_id', $user->id)->first();
     if (!$db_user) {
         $db_user = new User();
     }
     $db_user->fb_id = $user->id;
     $db_user->name = $user->name;
     $db_user->email = $user->email;
     $db_user->avatar = $user->avatar;
     $db_user->token = $user->token;
     $db_user->updated_time = $user->user['updated_time'];
     $db_user->verified = $user->user['verified'];
     $db_user->save();
     \Auth::login($db_user, true);
     return redirect($redirect);
 }
开发者ID:bancuadrian,项目名称:facebookphotocontest,代码行数:29,代码来源:UserController.php

示例3: handleProviderCallback

 /**
  * Obtain the user information from the Social Login Provider.
  *
  * @param string $provider
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 protected function handleProviderCallback($provider)
 {
     $user = $this->socialite->driver($provider)->user();
     $user = \App\User::whereEmail($user->getEmail())->first() ?: \App\User::create(['name' => $user->getName(), 'email' => $user->getEmail()]);
     \Auth::login($user, true);
     flash(trans('auth.welcome', ['name' => $user->name]));
     return redirect(route('home'));
 }
开发者ID:gabrieljo,项目名称:l5essential,代码行数:14,代码来源:SocialController.php

示例4: github

 public function github()
 {
     $user = Socialize::with('github')->user();
     Auth::login($user);
     // Do your stuff with user data.
     print_r($user);
     die;
     Redirect::intended('home');
 }
开发者ID:suprgyabhushan,项目名称:Woxx,代码行数:9,代码来源:AccountController.php

示例5: handleProviderCallback

 /**
  * Obtain the user information from $provider
  *
  * @return Response
  */
 public function handleProviderCallback($provider)
 {
     $user = Socialite::driver($provider)->user();
     $data = ['name' => $user->name, 'email' => 'info+' . $user->nickname . '@sapioweb.com', 'password' => bcrypt('oauthinstagram'), 'token' => $user->token, 'profile_id' => $user->id, 'avatar' => $user->avatar, 'username' => $user->nickname];
     $authUser = CrudHelper::createOrUpdate(new \App\User(), 'profile_id', $user->id, $data)->first();
     \Auth::login($authUser, true);
     return redirect()->route('home');
     // $user->token;
 }
开发者ID:SapioBeasley,项目名称:InteractStagram,代码行数:14,代码来源:OauthController.php

示例6: store

 /**
  * Store a newly created user in storage.
  *
  * @return Response
  */
 public function store(CreateUserRequest $request)
 {
     $user = new User($request->all());
     $user->password = \Hash::make($request->password);
     $user->type = 'user';
     $user->save();
     \Auth::login($user);
     \Session::put('auth_photo', '../default_avatar.jpg');
     return redirect()->route('newaccount');
 }
开发者ID:charlieboo,项目名称:creatrip,代码行数:15,代码来源:UserController.php

示例7: signin

 public function signin(Request $request)
 {
     $user = User::where('email', trim($request->input('username')))->orWhere('username', trim($request->input('username')))->first();
     if (!is_null($user)) {
         if (\Hash::check($request->get('password'), $user->password)) {
             \Auth::login($user);
             return redirect()->route('tasks.index');
         }
     }
     return redirect()->route('auth.login')->with("NOTIF_DANGER", 'Login Failed');
 }
开发者ID:abidnurulhakim,项目名称:qa-crawler,代码行数:11,代码来源:SiteController.php

示例8: createAccount

 /**
  * A user tries to register a native account.
  * S/he haven't logged in to the application with a social account before.
  *
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 protected function createAccount(Request $request)
 {
     $validator = \Validator::make($request->except('_token'), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         return back()->withInput()->withErrors($validator);
     }
     $user = User::create($request->except('_token'));
     \Auth::login($user);
     flash(trans('auth.welcome', ['name' => $user->name]));
     return redirect(route('home'));
 }
开发者ID:gabrieljo,项目名称:l5essential,代码行数:18,代码来源:UsersController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param AuthController $auth
  * @internal param Request $request
  * @return Response
  */
 public function store(AuthController $auth)
 {
     $data = Input::all();
     $valid = $auth->validator($data);
     if ($valid->fails()) {
         return redirect()->back()->withInput()->withErrors($valid);
     }
     $user = $auth->create($data);
     Auth::login($user);
     return redirect()->to('admin');
 }
开发者ID:jallowmamadou,项目名称:balance-1,代码行数:18,代码来源:AdminController.php

示例10: emailConfirmation

 public function emailConfirmation($data)
 {
     $json = base64_decode($data);
     $values = json_decode($json);
     $user = User::where("confirmation_code", "=", $values->confirmation_code)->where("email", "=", $values->email)->first();
     if (isset($user->id) && $user->id > 0) {
         $user = User::find($user->id);
         $user->update(["active" => 1]);
         \Auth::login($user);
         return redirect("/")->with("messages", "Welcome, you have been successfully registered!");
     }
 }
开发者ID:panicfilip,项目名称:Horizon-Polls,代码行数:12,代码来源:UserController.php

示例11: postLogin

 public function postLogin()
 {
     $credentials = \Input::only('email', 'password');
     $user = UserModel::where('email', \Input::get('email'))->first();
     // dd($user);
     if ($user and \Hash::check(\Input::get('password'), $user->password)) {
         Auth::login($user);
         flash('welcome in ' . auth()->user()->username, 'success');
         return redirect('/user/');
     } else {
         flash('unable to login', 'danger');
         return redirect('/user/login');
     }
 }
开发者ID:NablusTechMeetups,项目名称:web,代码行数:14,代码来源:UserController.php

示例12: signup

 public function signup()
 {
     $validation = User::validate(Input::all());
     if ($validation->passes()) {
         $user = array('fname' => Input::get('fname'), 'lname' => Input::get('lname'), 'year' => Input::get('year'), 'email' => Input::get('email'), 'password' => \Hash::make(Input::get('password')));
         User::create($user);
         $user_sign = User::whereemail(Input::get('email'))->first();
         \Auth::login($user_sign);
         Session::put('user_name', $user['email']);
         $score = DB::table('users')->where('email', Session::get('user_name'))->pluck('points');
         Session::put('pts', $score);
         return Redirect::to('dashboard')->with('message', 'Successfully Registered! Now you are logged in!');
     } else {
         return Redirect::to('signup')->withErrors($validation->errors())->withInput();
     }
 }
开发者ID:Nelabh,项目名称:lara,代码行数:16,代码来源:UserController.php

示例13: postReset

 /**
  * Handle a POST request to reset a user's password.
  *
  * @return Response
  */
 public function postReset()
 {
     $credentials = Input::only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $user->password = Hash::make($password);
         $user->save();
         Auth::login($user);
     });
     switch ($response) {
         case Password::INVALID_PASSWORD:
         case Password::INVALID_TOKEN:
         case Password::INVALID_USER:
             return Redirect::back()->with('error', Lang::get($response));
         case Password::PASSWORD_RESET:
             return Redirect::to('users/dashboard');
     }
 }
开发者ID:tommarshallandrews,项目名称:gloseventhire,代码行数:22,代码来源:RemindersController.php

示例14: postLogin

 public function postLogin()
 {
     $postValue = \Input::get('User');
     if ($this->loginService->checkLogin($postValue['email'], $postValue['password'])) {
         $user = $this->loginService->loadUser($postValue['email']);
         \Auth::login($user);
         if ($this->loginService->isFirstLogin($user->email)) {
             $response = route('profile.create');
         } else {
             $response = route('home');
         }
         $success = json_encode(['status' => 'success', 'response' => $response]);
         return response($success);
     }
     $fail = json_encode(['status' => 'failed', 'response' => $this->alertDanger('Gagal login')]);
     return response($fail);
 }
开发者ID:juliardi,项目名称:jualjasa,代码行数:17,代码来源:IndexController.php

示例15: login

 public function login(Request $request)
 {
     if (!$request->has('email') || !$request->has('password')) {
         return view('error')->with('error', 'Please provide all the fields.');
     }
     $input = $request->all();
     $user = \App\User::where('email', '=', $input['email'])->get()->first();
     if (count($user) != 1) {
         return view('error')->with('error', 'Couldn\'t find the user.');
     }
     if (!\Hash::check($input['password'], $user->password)) {
         return view('error')->with('error', 'Wrong password.');
     }
     \Auth::login($user);
     // return response()->json(['id' => \Auth::id()]);
     return redirect('/');
 }
开发者ID:simmimourya1,项目名称:Ruralfuse_final,代码行数:17,代码来源:EmployerController.php


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