本文整理汇总了PHP中App\Http\Controllers\Auth\Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Auth类的具体用法?PHP Auth怎么用?PHP Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLogout
/**
* Overwrite the getLogout function in Illuminate\Foundation\Auth\AuthenticatesUsers;
*/
public function getLogout()
{
\Auth::logout();
\Session::forget('cart_merge');
// custom feature
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/home');
}
示例2: redirectPath
public function redirectPath()
{
if (\Auth::user()->isUser('user')) {
return '/home';
}
return '/dashboard';
}
示例3: authenticate
public function authenticate ()
{
if (Auth::attempt(['mobile' => $mobile, 'password' => $password]))
{
return redirect()->intended('home');
}
}
示例4: 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 : '/');
}
示例5: 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)]);
}
}
示例6: getLogout
/**
* Override the default getLogout method.
* After logging out, unset/forget the jwt cookie.
*
* @return $this
*/
public function getLogout()
{
//unset the cookie
JWTService::unsetCookie();
\Auth::logout();
return redirect('/');
}
示例7: __construct
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
if (\Auth::check()) {
return redirect('/');
}
$this->middleware('guest', ['except' => 'getLogout']);
}
示例8: postLogin
public function postLogin(\App\Http\Requests\LoginUserRequest $request)
{
if (\Auth::attempt($request->except('_token'), true)) {
return redirect()->intended('/');
}
return back()->withInput()->with(['message' => 'Wrong email or password']);
}
示例9: postLogin
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function postLogin(\Illuminate\Http\Request $request)
{
if (\App::environment('local')) {
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
} else {
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required', 'g-recaptcha-response' => 'required|recaptcha']);
}
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (\Auth::attempt($credentials, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
}
示例10: login
public function login(Request $request)
{
// dd(\Crypt::encrypt('jtmccombs@gmail.com'));
try {
$email = \Crypt::decrypt($request->get('token'));
} catch (\Exception $e) {
return abort('403', 'Forbidden');
}
$user = User::whereEmail($email)->first();
if (!$user) {
return abort('403', 'Forbidden');
}
if (!$user->account) {
$b2bCompany = \DB::connection('mysql-b2b')->table('companies')->where('user_id', '=', $user->id)->first();
// $b2bCompany = false;
$accountName = $b2bCompany ? $b2bCompany->company_name : $user->email;
$account = new Account();
$account->ip = $request->getClientIp();
$account->name = $accountName;
$account->account_key = str_random(RANDOM_KEY_LENGTH);
$account->save();
$user->account_id = $account->id;
$user->registered = true;
$user->save();
$exists = \DB::connection('mysql')->table('users')->whereId($user->id)->count();
if (!$exists) {
\DB::connection('mysql')->table('users')->insert(['id' => $user->id, 'account_id' => $user->account_id, 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'deleted_at' => $user->deleted_at, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'phone' => $user->phone, 'username' => $user->username, 'email' => $user->email, 'password' => $user->password, 'confirmation_code' => $user->confirmation_code, 'registered' => $user->registered, 'confirmed' => $user->confirmed, 'notify_sent' => $user->notify_sent, 'notify_viewed' => $user->notify_viewed, 'notify_paid' => $user->notify_paid, 'public_id' => $user->public_id, 'force_pdfjs' => false, 'remember_token' => $user->remember_token, 'news_feed_id' => $user->news_feed_id, 'notify_approved' => $user->notify_approved, 'failed_logins' => $user->failed_logins, 'dark_mode' => $user->dark_mode, 'referral_code' => $user->referral_code]);
}
}
\Auth::loginUsingId($user->id);
return redirect('/');
}
示例11: 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');
}
示例12: 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();
}
示例13: logout
public function logout()
{
\Auth::logout();
// logout user
return \Redirect::to('admin/login');
//redirect back to login
}
示例14: getLogout
/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function getLogout()
{
\Auth::logout();
\Session::flash('flash_message', 'You are Logged Out.');
return redirect('/');
//return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
}
示例15: 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();
//
}