How to set different auth guard in laravel with auth0Why is my implementation of SSO using Ember-Simple-Auth with Auth0 getting stuck in a redirect loop?Angular2 auth guard with http request and observablesHow to enrich/extend Auth class/data in Laravel 5?Angular2 auth guard keeps track of current user with observableAuth0, Laravel 5.4 - after logout user is logged againLaravel session and auth issue in MacOSLaravel Multi Auth - Admin Guardcustom auth guard not logging in laravelAuth::user() is not working for Guard authentication in laravel 5.6Auth Laravel check authentication of user not working in custom controller

USA: Can a witness take the 5th to avoid perjury?

What to do when you reach a conclusion and find out later on that someone else already did?

How do I stop my characters falling in love?

Inadvertently nuked my disk permission structure - why?

How acidic does a mixture have to be for milk to curdle?

How do we explain the E major chord in this progression?

What is the effect and/or good reasons of changing a paper bill to a coin?

Heisenberg uncertainty principle in daily life

What is the lowest-speed bogey a jet fighter can intercept/escort?

What does "see" in "the Holy See" mean?

What do teaching faculty do during semester breaks?

Marrying a second woman behind your wife's back: is it wrong and can Quran/Hadith prove this?

A planet illuminated by a black hole?

This message is flooding my syslog, how to find where it comes from?

How do campaign rallies gain candidates votes?

Character is called by their first initial. How do I write it?

Why was Sauron preparing for war instead of trying to find the ring?

Singapore to Sydney to Canberra: where do we clear customs

How can I stop myself from micromanaging other PCs' actions?

Can two figures have the same area, perimeter, and same number of segments have different shape?

Why isn't there a serious attempt at creating a third mass-appeal party in the US?

Does the Intel 8086 CPU have user mode and kernel mode?

Explain why watch 'jobs' does not work but watch 'ps' work?

Is there a reason why I should not use the HaveIBeenPwned API to warn users about exposed passwords?



How to set different auth guard in laravel with auth0


Why is my implementation of SSO using Ember-Simple-Auth with Auth0 getting stuck in a redirect loop?Angular2 auth guard with http request and observablesHow to enrich/extend Auth class/data in Laravel 5?Angular2 auth guard keeps track of current user with observableAuth0, Laravel 5.4 - after logout user is logged againLaravel session and auth issue in MacOSLaravel Multi Auth - Admin Guardcustom auth guard not logging in laravelAuth::user() is not working for Guard authentication in laravel 5.6Auth Laravel check authentication of user not working in custom controller






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am work on laravel with auth0 project (package is auth0/login).



My project has local auth users.



I am going to add auth method with auth0, so I have set auth config for auth0.



This is my /config/auth.php code



 'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],


],


 'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],

],


this is my callback route's controller function.




public function auth0SigninCallback()


//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();

$auth0User = $userRepo->getUserByUserInfo($profile);

return response()->json($auth0User);



Auth::guard('auth0web)->user();
At this code I am getting null for auth user.



$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.



PS
This is my session data maybe that is correctly




"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true




I have try override callback route controller



this is code



 // Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);

if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;

Auth::guard('auth0web')->login($user, $service->rememberUser());

// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}


at this time auth() is correctly working



but while redirecting to home Auth is initialized



this is my custom middleware.



 public function handle($request, Closure $next)

// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);




At this part I'm getting null from auth()->user()










share|improve this question
























  • SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶

    – Loveun CG
    Mar 27 at 0:51











  • This is result of dd(Auth::guard('auth0web'));

    – Loveun CG
    Mar 27 at 0:52

















0















I am work on laravel with auth0 project (package is auth0/login).



My project has local auth users.



I am going to add auth method with auth0, so I have set auth config for auth0.



This is my /config/auth.php code



 'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],


],


 'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],

],


this is my callback route's controller function.




public function auth0SigninCallback()


//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();

$auth0User = $userRepo->getUserByUserInfo($profile);

return response()->json($auth0User);



Auth::guard('auth0web)->user();
At this code I am getting null for auth user.



$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.



PS
This is my session data maybe that is correctly




"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true




I have try override callback route controller



this is code



 // Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);

if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;

Auth::guard('auth0web')->login($user, $service->rememberUser());

// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}


at this time auth() is correctly working



but while redirecting to home Auth is initialized



this is my custom middleware.



 public function handle($request, Closure $next)

// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);




At this part I'm getting null from auth()->user()










share|improve this question
























  • SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶

    – Loveun CG
    Mar 27 at 0:51











  • This is result of dd(Auth::guard('auth0web'));

    – Loveun CG
    Mar 27 at 0:52













0












0








0








I am work on laravel with auth0 project (package is auth0/login).



My project has local auth users.



I am going to add auth method with auth0, so I have set auth config for auth0.



This is my /config/auth.php code



 'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],


],


 'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],

],


this is my callback route's controller function.




public function auth0SigninCallback()


//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();

$auth0User = $userRepo->getUserByUserInfo($profile);

return response()->json($auth0User);



Auth::guard('auth0web)->user();
At this code I am getting null for auth user.



$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.



PS
This is my session data maybe that is correctly




"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true




I have try override callback route controller



this is code



 // Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);

if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;

Auth::guard('auth0web')->login($user, $service->rememberUser());

// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}


at this time auth() is correctly working



but while redirecting to home Auth is initialized



this is my custom middleware.



 public function handle($request, Closure $next)

// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);




At this part I'm getting null from auth()->user()










share|improve this question
















I am work on laravel with auth0 project (package is auth0/login).



My project has local auth users.



I am going to add auth method with auth0, so I have set auth config for auth0.



This is my /config/auth.php code



 'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'auth0web'=>[
'driver' => 'session',
'provider' => 'auth0_users',
],


],


 'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppUser::class,
],
'auth0_users'=>[
'driver' => 'auth0'
],

],


this is my callback route's controller function.




public function auth0SigninCallback()


//return response()->json(Auth:: guard('auth0web)->user());
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
$userRepo = new Auth0UserRepository();

$auth0User = $userRepo->getUserByUserInfo($profile);

return response()->json($auth0User);



Auth::guard('auth0web)->user();
At this code I am getting null for auth user.



$profile is correctly getting for now.
how can I get different guard(Auth::guard('auth0web')->user()) for auth
Thanks for your advance.



PS
This is my session data maybe that is correctly




"_token": "OAmhhYKWeO0tK6E5FN3DHaRvVYx6PP7z0YPMAPrz",
"_previous":
"url": "http://xxxxx.dev/login"
,
"_flash":
"old": [],
"new": []
,
"auth0__user": xxxxxxxxxxx",
"nickname": "xxxxxxxx",
"name": "xxxxx@xxxxx.com",
"picture": "https://s.gravatar.com/avatar/xxxx.png",
"updated_at": "2019-03-26T17:28:53.981Z",
"email": "xxxxxx@ixxx.com",
"email_verified": true




I have try override callback route controller



this is code



 // Get a handle of the Auth0 service (we don't know if it has an alias)
$service = App::make('auth0');

// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRepository->getUserByUserInfo($profile);

if ($auth0User)
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin())
$user = $service->callOnLogin($auth0User);
else
// If not, the user will be fine
$user = $auth0User;

Auth::guard('auth0web')->login($user, $service->rememberUser());

// dd(auth());
// Log::info(auth()->user());
return Redirect::intended('/home');
}


at this time auth() is correctly working



but while redirecting to home Auth is initialized



this is my custom middleware.



 public function handle($request, Closure $next)

// Log::info('------------here---------');
// dd(auth());
$auth = Auth::user() ?? Auth::guard('ldap')->user();
// dd(auth());
// Log::info(auth()->user());
if (!isset($auth->id))
return redirect('login');
else
return $next($request);




At this part I'm getting null from auth()->user()







laravel authentication auth0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 2:41







Loveun CG

















asked Mar 26 at 17:14









Loveun CGLoveun CG

61 silver badge7 bronze badges




61 silver badge7 bronze badges












  • SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶

    – Loveun CG
    Mar 27 at 0:51











  • This is result of dd(Auth::guard('auth0web'));

    – Loveun CG
    Mar 27 at 0:52

















  • SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶

    – Loveun CG
    Mar 27 at 0:51











  • This is result of dd(Auth::guard('auth0web'));

    – Loveun CG
    Mar 27 at 0:52
















SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶

– Loveun CG
Mar 27 at 0:51





SessionGuard #489 ▼ #name: "auth0web" #lastAttempted: null #viaRemember: false #session: Store #430 ▶ #cookie: CookieJar #428 ▶ #request: Request #42 ▶ #events: Dispatcher #26 ▶ #loggedOut: false #recallAttempted: false #user: null #provider: Auth0UserProvider #473 ▶

– Loveun CG
Mar 27 at 0:51













This is result of dd(Auth::guard('auth0web'));

– Loveun CG
Mar 27 at 0:52





This is result of dd(Auth::guard('auth0web'));

– Loveun CG
Mar 27 at 0:52












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362769%2fhow-to-set-different-auth-guard-in-laravel-with-auth0%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362769%2fhow-to-set-different-auth-guard-in-laravel-with-auth0%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해