本文整理汇总了PHP中App\Http\Middleware\Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Auth类的具体用法?PHP Auth怎么用?PHP Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $role)
{
if (!\Auth::user()->{$role}) {
return \App::abort(401, 'You are not allowed to access this resource.');
}
return $next($request);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $role)
{
if (\Auth::user()->can($role . '-access')) {
return $next($request);
}
return response('Unauthorized.', 401);
}
示例3: userStatte
public static function userStatte()
{
$state = true;
if (\Auth::User() == null) {
$state = false;
}
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request Request Object
* @param \Closure $next Closure Object
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!\Auth::user()->hasRole('admin')) {
return response('Unauthorized.', 401);
}
return $next($request);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->connections()->where('connection_id', '=', $request->segment(3))->count() == 0) {
return $next($request);
}
return redirect()->back()->withErrors(['Already Connected', 'You can not connect with this person cause the connection already exists.']);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->nivelAccess == 1) {
return redirect('/mbl');
}
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)
{
if (\Auth::check('admin')) {
return redirect('/systems');
}
return $next($request);
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $roleName)
{
if (Auth::check() && !Auth::user()->hasRole($roleName)) {
return abort(401, 'Unauthorized');
}
return $next($request);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!(\Auth::check() && \Auth::user()->isAdmin())) {
return redirect('/')->withErrors('Access denied to ADMIN functionality!');
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->ref_user_level_id != 3) {
return response('akses ditolak', 401);
}
return $next($request);
}
示例11: handle
public function handle($request, Closure $next)
{
if (\Auth::check() && \Auth::user()->isNotChild() && \Auth::user()->isActive()) {
return $next($request);
}
return redirect('home');
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$uri_segments = $request->segments();
if (!empty($uri_segments) && in_array("api", $uri_segments)) {
return $next($request);
}
if (\Auth::guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('http://login.' . \Config::get('app.domain') . '/');
}
}
$usuario = \Auth::user();
if (!empty($usuario)) {
//Menú de administrador
if ($usuario->hasRole('administrador')) {
\Menu::make('menu_lateral', function ($menu) {
$menu->add('Inicio', 'inicio');
});
}
} else {
\Redirect::to('/error500');
}
return $next($request);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::guest() || !$request->user()->isAdmin()) {
return redirect('/');
}
return $next($request);
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!in_array(\Auth::user()->user_type, config('squash.club+member'))) {
return redirect('notifications/club-notices');
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!(\Auth::check() && !\Auth::user()->isBanned())) {
return redirect('banned')->withErrors('User is banned.');
}
return $next($request);
}