本文整理汇总了PHP中Illuminate\Support\Facades\Auth::guard方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::guard方法的具体用法?PHP Auth::guard怎么用?PHP Auth::guard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::guard方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function login(Request $request)
{
$loginusername = $this->loginUsername();
$this->validate($request, [$loginusername => 'required', 'password' => 'required']);
// 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);
$possiblecolumns = $this->loginColumns();
$templogin = $credentials[$loginusername];
unset($credentials[$loginusername]);
foreach ($possiblecolumns as $column) {
$credentials[$column] = $templogin;
if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
}
unset($credentials[$column]);
}
// 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 $this->sendFailedLoginResponse($request);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check() && !$request->is("register")) {
return redirect('/');
}
return $next($request);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
// Check for the guard and redirect accordingly
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} elseif ($guard == 'student') {
return redirect()->guest('/students/login');
} elseif ($guard == 'teacher') {
return redirect()->guest('/teachers/login');
} elseif ($guard == 'hostelStaff') {
return redirect()->guest('/hostelStaffs/login');
} elseif ($guard == 'libraryStaff') {
return redirect()->guest('/libraryStaffs/login');
} elseif ($guard == 'departmentStaff') {
return redirect()->guest('/departmentStaffs/login');
} elseif ($guard == 'chiefWardenStaff') {
return redirect()->guest('/chiefWardenStaffs/login');
} elseif ($guard == 'adminStaff') {
return redirect()->guest('/adminStaffs/login');
} elseif ($guard == 'admin') {
return redirect()->guest('/admins/login');
}
}
return $next($request);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (!Auth::check() || !Auth::guard($guard)->user()->admin) {
return redirect('/');
}
return $next($request);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
null;
}
return $next($request);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return abort(401, "The user is already logged");
}
return $next($request);
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
$this->killDeadCookies($request);
}
return $next($request);
}
示例8: myAccountOrderList
public function myAccountOrderList()
{
$user = Auth::guard('web')->user();
$orders = Order::where('user_id', '=', $user->id)->get();
$view = view('order.my-account-order-list')->with('orders', $orders);
return $view;
}
示例9: getLogout
/**
* Logout manager.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function getLogout()
{
Auth::guard($this->guard)->logout();
flash()->success(trans('messages.logout.title'), trans('messages.logout.content'));
event('manager.logged_out');
return redirect(route('admin.login'));
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param Guard $guard
*
* @return mixed
*/
public function handle(Request $request, Closure $next, Guard $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(route('home_path'));
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = 'admin')
{
if (Auth::guard($guard)->check()) {
return redirect('/admin');
}
return $next($request);
}
示例12: getLogin
public function getLogin(Request $request)
{
//Check Remember
if (Auth::guard('admin')->viaRemember()) {
return redirect('/');
}
//Check Login
if (Auth::guard('admin')->check()) {
return redirect('/');
}
//Do login
if ($request->method() == 'POST') {
$data = $request->only('email', 'password', 'remember');
if ($data['remember'] == 'remember_me') {
$this->remember = true;
}
$attempt = Auth::guard('admin')->attempt(['email' => $data['email'], 'password' => $data['password']], $this->remember);
if ($attempt) {
return redirect('/');
} else {
$request->session()->flash('Errors', 'Email or password is wrong');
return redirect()->back()->withInput();
}
}
return view('backend/login/index')->with(['title' => $this->title]);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (!Auth::guard($guard)->guest()) {
return redirect(route('admin:index'));
}
return $next($request);
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect()->intended('/home');
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (!Auth::guard('admin')->check()) {
return "hata !";
}
//return $next($request);
}