本文整理汇总了PHP中App\Http\Controllers\Auth\Auth::login方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::login方法的具体用法?PHP Auth::login怎么用?PHP Auth::login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Auth\Auth
的用法示例。
在下文中一共展示了Auth::login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleProviderCallback
public function handleProviderCallback()
{
//$user = Socialite::with('facebook')->user();
//dd($user);
try {
$user = Socialite::with('facebook')->user();
} catch (Exception $e) {
return redirect('/login/facebook');
}
dd($user);
$authUser = $this->findOrCreateUser($user);
Auth::login($authUser, true);
return redirect('/home');
// // OAuth Two Providers
// $token = $user->token;
//
//// OAuth One Providers
// $token = $user->token;
// $tokenSecret = $user->tokenSecret;
//
//// All Providers
// $user->getId();
// $user->getNickname();
// $user->getName();
// $user->getEmail();
// $user->getAvatar();
//
}
示例2: __construct
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
// http://fallout.dev/home?autologin
$user = User::where('email', 'test@example.com')->get();
if (!empty($user[0])) {
\Auth::login($user[0]);
}
$this->middleware('guest', ['except' => 'getLogout']);
}
示例3: getFacebookCallback
public function getFacebookCallback()
{
$user = \Socialize::with('facebook')->user();
// All Providers
$user->provider = "facebook";
$user = User::findByUserNameOrCreate($user);
\Auth::login($user);
return redirect()->intended('home');
}
示例4: providerLogin
public function providerLogin($provider)
{
// ユーザー情報取得
$userData = \Socialite::with($provider)->user();
// ユーザー作成
$user = App\Models\User::firstOrCreate(['name' => $userData->nickname, 'email' => $userData->email, 'avatar' => $userData->avatar]);
\Auth::login($user);
return redirect('/');
}
示例5: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
\Auth::login($this->create($request->all()));
flash()->success('Register successful');
return redirect($this->redirectPath());
}
示例6: postRegister
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
$user = $this->create($request->all());
\Auth::login($user);
return ['key' => $user->key->key, 'admin' => $user->admin == '1' ? true : false];
}
示例7: postRegister
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$request->session()->flash('loginTab', 'register');
$this->throwValidationException($request, $validator);
}
\Auth::login($this->create($request->all()));
return redirect($this->redirectPath());
}
示例8: handleProviderCallback
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleProviderCallback()
{
/*
Sample of what LinkedIn returns
---------------------
User {#149 ▼
+token: "AQUmcn8FTAYmj_-IkAPzcqCxhZRNR-woIX9-fH4JEvCzb7xICTy2uY3JXXiq1co8MFUxxiBsk3IJIeE2kTlH5mP6fRtBnQConCaX2F2BB6fOtbswLmcSio8M1lEo67Nrt7yXbjJueAlz4wPt4T5knXZjV95uPcP0q2XEQG5Jw0zRUhNLcKY"
+id: "nZmvBPf-nh"
+nickname: null
+name: "Ben Allfree"
+email: "ben@benallfree.com"
+avatar: "https://media.licdn.com/mpr/mprx/0_NFyu8TZPvM4g9_tqnbS18GglvUyPN_tqn5e18GxTEZe_wF5N43u8aCI7U1puckP4vXYt75Tc0GEr"
+"user": array:11 [▼
"emailAddress" => "ben@benallfree.com"
"firstName" => "Ben"
"formattedName" => "Ben Allfree"
"headline" => "I turn ideas into working software."
"id" => "nZmvBPf-nh"
"industry" => "Computer Software"
"lastName" => "Allfree"
"location" => array:2 [▼
"country" => array:1 [▼
"code" => "us"
]
"name" => "Reno, Nevada Area"
]
"pictureUrl" => "https://media.licdn.com/mpr/mprx/0_NFyu8TZPvM4g9_tqnbS18GglvUyPN_tqn5e18GxTEZe_wF5N43u8aCI7U1puckP4vXYt75Tc0GEr"
"pictureUrls" => array:2 [▼
"_total" => 1
"values" => array:1 [▼
0 => "https://media.licdn.com/mpr/mprx/0_Y7yIKlXzoK8T6SZtx7PLnrvBolli3aZtxmGQnKEMXzr86fopjxjFqnbjkJ-"
]
]
"publicProfileUrl" => "https://www.linkedin.com/in/benallfree"
]
+"avatar_original": "https://media.licdn.com/mpr/mprx/0_Y7yIKlXzoK8T6SZtx7PLnrvBolli3aZtxmGQnKEMXzr86fopjxjFqnbjkJ-"
}
*/
$data = Socialite::driver('linkedin')->user();
$user = User::whereLinkedinId($data->id)->first();
if (!$user) {
$user = new User();
$user->linkedin_id = $data->id;
}
$user->email = $data->email;
$user->firstname = $data->user['firstName'];
$user->lastname = $data->user['lastName'];
$user->country = $data->user['location']['country']['code'];
$user->location = $data->user['location']['name'];
$user->tagline = $data->user['headline'];
$user->avatar_url = $data->avatar_original;
$user->save();
\Auth::login($user);
return redirect()->route('home')->with('success', "Welcome back, {$user->firstname}");
}
示例9: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
\Auth::login($this->create($request->all()));
// save the hashtag terms stored in the global session to the database
$this->saveStoredHashtags();
return redirect($this->redirectPath());
}
示例10: handleProviderCallback
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleProviderCallback()
{
try {
$user = Socialite::driver('facebook')->user();
} catch (Exception $e) {
return \Redirect::to('auth/facebook');
}
$authUser = $this->findOrCreateUser($user);
\Auth::login($authUser, true);
return \Redirect::to('/');
}
示例11: getSocialAuthCallback
public function getSocialAuthCallback($provider = null)
{
try {
$user = $this->socialite->with($provider)->user();
} catch (Exception $e) {
return redirect(null, 404);
}
$authUser = $this->findOrCreateUser($user);
\Auth::login($authUser, true);
return redirect()->route('home');
//TODO : redirect to error page
}
示例12: getSocialAuthCallback
public function getSocialAuthCallback($provider = null)
{
if ($user = $this->socialite->with($provider)->user()) {
$authUser = $this->findOrCreateUser($user, $provider);
// Log in
\Auth::login($authUser, true);
// Return
return \Redirect::intended();
} else {
return 'something went wrong';
}
}
示例13: postRegister
/**
* Overriding from E:\Wamp\wamp\www\tagoal\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers
*/
public function postRegister(Request $request, AppMailer $mailer)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
// $user = $this->create($request->all());
// $mailer -> sendEmailConfirmationTo($user);
// return 1;
\Auth::login($this->create($request->all()));
return redirect($this->redirectPath());
}
示例14: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
try {
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
\Auth::login($this->create($request->all()));
return redirect($this->redirectPath());
} catch (FailedPasswordValidationException $e) {
dd($e);
}
}
示例15: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$fields = $request->only(['name', 'email', 'country', 'password', 'password_confirmation']);
$validator = $this->validator($fields);
if ($validator->fails()) {
return \Response::json(['success' => false, 'errors' => $validator->errors()]);
}
$user = $this->create($request->all());
\Auth::login($user);
if (!$request->ajax()) {
return redirect($this->redirectPath())->with(['message' => "You're finally registered, {$user->name}"]);
}
return \Response::json(['success' => true]);
}