本文整理汇总了PHP中App\Http\Middleware\Auth::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::user方法的具体用法?PHP Auth::user怎么用?PHP Auth::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Middleware\Auth
的用法示例。
在下文中一共展示了Auth::user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request. User must be logged in to do admin check
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->is_admin == 1) {
return $next($request);
}
return redirect()->guest('/');
}
示例2: 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.']);
}
示例3: 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);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->salesman_yn == 'Y') {
return $next($request);
}
return redirect('/');
}
示例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()->nivelAccess == 1) {
return redirect('/mbl');
}
return $next($request);
}
示例6: handle
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$route = \Route::getCurrentRoute();
// $route->uri(), $request->path()
$roles = \Auth::user()->roles;
$allow = true;
try {
// Check if route has permission
foreach ($roles as $role) {
foreach ($role->permissions as $permission) {
$allow = $allow & !$this->denied($request, $route, $permission);
}
}
} catch (\Exception $e) {
\Log::error($e->getFile() . ':' . $e->getLine() . ' ' . $e->getMessage());
$allow = false;
}
// Apply access
\Log::info('ACCESS:' . \Auth::user()->name . ':' . $request->method() . ':' . $request->path() . ':' . ($allow ? 'ALLOWED' : 'DENIED'));
if (!$allow) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return response(view('admin/unauthorized'), 401);
}
} else {
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::user()->isSudo()) {
return $next($request);
}
return redirect('/');
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->role != 'admin') {
return "This page for only ADMIN!";
}
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)
{
$siteID = $request->route('sites');
$site = \App\Models\Site::find($siteID);
// normal and admin users accessing other site info
if (\Auth::user()->super == "No") {
if (\Auth::user()->site_id != $siteID) {
if ($request->ajax()) {
return response('Unauthorized', 401);
} else {
return redirect()->guest('noAccess');
}
}
}
// if super user is trying to access a site belonging to another company
if (\Auth::user()->super == "Yes") {
if (\Auth::user()->site->company_id != $site->company_id) {
if ($request->ajax()) {
return response('Unauthorized', 401);
} else {
return redirect()->guest('noAccess');
}
}
}
return $next($request);
}
示例10: handle
/**
* filtre pour protéger les étudiants de prendre certaines routes
* Note: pourrait probablement être remplacé par un système comme Sentry, mais ca fait la job pour l'instant.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->type != 'p') {
return redirect('/home');
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::user()->can('can_view_dashboard')) {
return response('Unauthorized.', 401);
}
return $next($request);
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check() && \Auth::user()->isActive()) {
return redirect('./home');
}
return $next($request);
}
开发者ID:bradsmithcan,项目名称:laravel_infusionsoft_constantcontact,代码行数:14,代码来源:RedirectIfAuthenticated.php
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user()->level() < 4) {
abort(403, "¡Usted no tiene los permisos para ingresar a este proceso.");
}
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 (\Auth::user()->team_id) {
return redirect()->action('TeamsController@show');
}
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, $roleName)
{
if (Auth::check() && !Auth::user()->hasRole($roleName)) {
return abort(401, 'Unauthorized');
}
return $next($request);
}