本文整理汇总了PHP中Auth::guard方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::guard方法的具体用法?PHP Auth::guard怎么用?PHP Auth::guard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::guard方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
//get the admin check closure that should be supplied in the config
/** @var CmfConfig $configs */
$configs = CmfConfig::getInstance();
//if this is a simple false value, send the user to the login redirect
$response = \Auth::guard()->check() && $configs->isAuthorised($request);
if (!$response) {
$loginUrl = route($configs->login_route());
$redirectUri = $request->url();
if ($request->ajax()) {
\Session::set(CmfConfig::getInstance()->session_redirect_key(), $redirectUri);
return response()->json(['redirect_with_reload' => $loginUrl], HttpCode::UNAUTHORISED);
} else {
return redirect()->guest($loginUrl)->with(CmfConfig::getInstance()->session_redirect_key(), $redirectUri);
}
} else {
if (is_a($response, 'Illuminate\\Http\\JsonResponse') || is_a($response, 'Illuminate\\Http\\Response')) {
return $response;
} else {
if (is_a($response, 'Illuminate\\Http\\RedirectResponse')) {
$redirectUri = $request->url();
/** @var RedirectResponse $response */
return $response->with(CmfConfig::getInstance()->session_redirect_key(), $redirectUri);
}
}
}
return $next($request);
}
示例2: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->composer('layout.admin', function ($view) {
$usuario = Manager::with('company')->where('id', '=', \Auth::guard('web_managers')->user()->id)->firstOrFail();
$json = json_decode($usuario->company->configuracoes);
if ($json) {
$corPainel = $json->config->cores->cor;
$dados['corPainel'] = $corPainel;
Cookie::queue(Cookie::make('corPainel', $json->config->cores, 2628000));
}
$dados['usuario'] = $usuario;
$view->with($dados);
});
view()->composer('errors.404', function ($view) {
$dados = [];
$cookie = Cookie::get('corPainel');
if ($cookie) {
$cookie = Crypt::decrypt($cookie);
$dados['corPainel'] = $cookie->cor;
}
$view->with($dados);
});
view()->composer('layout.login', function ($view) {
$cookie = Cookie::get('corPainel');
if ($cookie) {
$cores = ['bgm-white' => '#ffffff', 'bgm-black' => '#000000', 'bgm-brown' => '#795548', 'bgm-pink' => '#e91e63', 'bgm-red' => '#f44336', 'bgm-blue' => '#2196f3', 'bgm-purple' => '#9c27b0', 'bgm-deeppurple' => '#673ab7', 'bgm-lightblue' => '#03a9f4', 'bgm-cyan' => '#00bcd4', 'bgm-teal' => '#009688', 'bgm-green' => '#4caf50', 'bgm-lightgreen' => '#8bc34a', 'bgm-lime' => '#cddc39', 'bgm-yellow' => '#ffeb3b', 'bgm-amber' => '#ffc107', 'bgm-orange' => '#ff9800', 'bgm-deeporange' => '#ff5722', 'bgm-gray' => '#9e9e9e', 'bgm-bluegray' => '#607d8b', 'bgm-indigo' => '#3f51b5'];
$corHex = $cores[$cookie->cor];
$dados['corHex'] = $corHex;
}
$dados['corPainel'] = $cookie;
$view->with($dados);
});
}
示例3: getLikedAttribute
/**
* Get the comment's user_id attribute.
*
* @return bool
*/
public function getLikedAttribute()
{
if (!\Auth::guard()->check()) {
return false;
}
return $this->likes()->where('user_id', \Auth::guard()->user()->getAuthIdentifier())->exists();
}
示例4: handle
public function handle($request, \Closure $next, $guard = null)
{
if (\Auth::guard($guard)->check()) {
return redirect()->route('admin');
}
return $next($request);
}
示例5: create
public static function create()
{
self::$urls = \Config::get('panel.panelControllers');
$config = \Serverfireteam\Panel\Link::allCached();
$dashboard = array();
$appHelper = new AppHelper();
// Make Dashboard Items
foreach ($config as $value) {
$modelName = $value['url'];
if (in_array($modelName, self::$urls)) {
$model = "Serverfireteam\\Panel\\" . $modelName;
} else {
$model = $appHelper->getNameSpace() . $modelName;
}
//if (class_exists($value)) {
if ($value['show_menu']) {
$user = \Auth::guard('panel')->user();
if (!$user->hasRole('super')) {
if (!\Auth::guard('panel')->user()->hasPermission($modelName . 'all')) {
continue;
}
}
$dashboard[] = array('modelName' => $modelName, 'title' => $value['display'], 'count' => $model::count(), 'showListUrl' => 'panel/' . $modelName . '/all', 'addUrl' => 'panel/' . $modelName . '/edit');
}
}
return $dashboard;
}
示例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 redirect(addon()->config('addon.routes.landing', '/'));
}
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 (is_null(\Auth::guard('panel')->user())) {
$message = session('message', Lang::get('panel::fields.enterEmail'));
return redirect('/panel/login')->with('message', $message)->with('mesType', 'message');
}
return $next($request);
}
示例8: __construct
function __construct()
{
if (\Auth::guard('web')->check()) {
$this->user_grade = \Auth::user()->grade;
} else {
$this->user_grade = 0;
}
}
示例9: verify
public function verify($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
if (\Auth::guard($this->guard)->once($credentials)) {
return \Auth::guard($this->guard)->user()->id;
}
return false;
}
示例10: create
public function create($id)
{
$cliente = Client::with('info')->where('id', '=', $id)->first();
$company = Company::with('managers')->where('id', '=', \Auth::guard('web_managers')->user()->company_id)->firstOrFail();
$config = json_decode($company->configuracoes);
$tiposEvento = ArrayObjToArray($config->config->tipoEvento);
return view('admin.orcamento.create', compact('cliente', 'config', 'tiposEvento', 'company'));
}
示例11: checkLoggedIn
public function checkLoggedIn()
{
$temp = \Config::get('auth.model');
\Config::set('auth.model', 'Serverfireteam\\Panel\\Admin');
$access = !\Auth::guard('panel')->guest();
\Config::set('auth.model', $temp);
return $access;
}
示例12: alteraConfigs
public function alteraConfigs(Request $request)
{
$company = Company::find(\Auth::guard('web_managers')->user()->company_id);
$company->configuracoes = $request->config;
$configs = json_decode($company->configuracoes);
Cookie::queue(Cookie::make('corPainel', $configs->config->cores, 2628000));
$company->save();
return 'true';
}
示例13: it_keeps_track_of_the_token
/** @test */
public function it_keeps_track_of_the_token()
{
Auth::guard('jwt')->attempt($this->getCorrectCredentials());
$token = Auth::guard('jwt')->token();
$this->assertInstanceOf('\\Vercoutere\\LaravelJwt\\Token', $token);
Auth::guard('jwt')->logout();
$this->assertFalse(Auth::guard('jwt')->token());
Auth::guard('jwt')->authenticateWithToken($token);
$this->assertInstanceOf('\\Vercoutere\\LaravelJwt\\Token', Auth::guard('jwt')->token());
}
示例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)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest(addon()->config('addon.routes.login', '/login'));
}
}
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($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
return $next($request);
}