Laravel guest middlewareLaravel 5 Protecting Routes with MiddlewareLaravel 5: Middleware don't work as expectedLaravel 5.2.14 with Duxet/RethinkDB Authentication Redirect User Seen as Guest in Home Routelaravel authentication always guestLaravel 5 restrict access to pages using middlewareLaravel middleware with multiple rolesLaravel - Confusion between routes and middleware and VueRouterCustom Middleware - 'Too Many Redirects' - LaravelCustom Middleware - Too Many Redirects - LaravelLaravel- 'auth' middleware not work
Java TreeMap.floorKey() equivalent for std::map
Methodology: Writing unit tests for another developer
Can someone suggest a path to study Mordell-Weil theorem for someone studying on their own?
Is a single radon-daughter atom in air a solid?
What is "industrial ethernet"?
Parameterize chained calls to a utility program in Bash
How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?
What size of powerbank will I need to power a phone and DSLR for 2 weeks?
Can humans ever directly see a few photons at a time? Can a human see a single photon?
What is the origin of Scooby-Doo's name?
Really Old Stock Valuation
Would it be a copyright violation if I made a character’s full name refer to a song?
What can I do with a research project that is my university’s intellectual property?
Do I have to explain the mechanical superiority of the player-character within the fiction of the game?
Can there be an UN resolution to remove a country from the UNSC?
How does a pilot select the correct ILS when the airport has parallel runways?
Has there been any indication at all that further negotiation between the UK and EU is possible?
Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?
Array initialization optimization
What does it mean to "control target player"?
Dates on degrees don’t make sense – will people care?
How to make clear to people I don't want to answer their "Where are you from?" question?
Greeting with "Ho"
Trainee keeps missing deadlines for independent learning
Laravel guest middleware
Laravel 5 Protecting Routes with MiddlewareLaravel 5: Middleware don't work as expectedLaravel 5.2.14 with Duxet/RethinkDB Authentication Redirect User Seen as Guest in Home Routelaravel authentication always guestLaravel 5 restrict access to pages using middlewareLaravel middleware with multiple rolesLaravel - Confusion between routes and middleware and VueRouterCustom Middleware - 'Too Many Redirects' - LaravelCustom Middleware - Too Many Redirects - LaravelLaravel- 'auth' middleware not work
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a page in my web app that should be blocked from logged in users. Similar to how a login or register page should not be accessible to already logged in users. I accomplished this by using guest middleware in controller constructor.
$this->middleware("guest")->only("page_action"); // like this
In this setup, if logged in user tries to visit that page they get redirected to home page. But I need to show a 404 not found page instead of redirecting. How can I do that?
In short, how can I make a page accessible to guest only and make it look like it does not exist to logged in users?
laravel-5 laravel-middleware laravel-5.8
add a comment |
I have a page in my web app that should be blocked from logged in users. Similar to how a login or register page should not be accessible to already logged in users. I accomplished this by using guest middleware in controller constructor.
$this->middleware("guest")->only("page_action"); // like this
In this setup, if logged in user tries to visit that page they get redirected to home page. But I need to show a 404 not found page instead of redirecting. How can I do that?
In short, how can I make a page accessible to guest only and make it look like it does not exist to logged in users?
laravel-5 laravel-middleware laravel-5.8
add a comment |
I have a page in my web app that should be blocked from logged in users. Similar to how a login or register page should not be accessible to already logged in users. I accomplished this by using guest middleware in controller constructor.
$this->middleware("guest")->only("page_action"); // like this
In this setup, if logged in user tries to visit that page they get redirected to home page. But I need to show a 404 not found page instead of redirecting. How can I do that?
In short, how can I make a page accessible to guest only and make it look like it does not exist to logged in users?
laravel-5 laravel-middleware laravel-5.8
I have a page in my web app that should be blocked from logged in users. Similar to how a login or register page should not be accessible to already logged in users. I accomplished this by using guest middleware in controller constructor.
$this->middleware("guest")->only("page_action"); // like this
In this setup, if logged in user tries to visit that page they get redirected to home page. But I need to show a 404 not found page instead of redirecting. How can I do that?
In short, how can I make a page accessible to guest only and make it look like it does not exist to logged in users?
laravel-5 laravel-middleware laravel-5.8
laravel-5 laravel-middleware laravel-5.8
asked Mar 25 at 8:46
RagasRagas
686721
686721
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
In your method just check if the user is loggedIn, if then abort to 404 like below...
if(IlluminateSupportFacadesAuth::check())
return abort(404);
#Rest of the code is for guest user.....
#
add a comment |
The guest logic is inside inside AppHttpMiddlewareRedirectIfAuthenticated
.
if (Auth::guard($guard)->check())
abort(404)
return $next($request);
Otherwise, you need to create a new middleware like @Atiqur suggested.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334032%2flaravel-guest-middleware%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your method just check if the user is loggedIn, if then abort to 404 like below...
if(IlluminateSupportFacadesAuth::check())
return abort(404);
#Rest of the code is for guest user.....
#
add a comment |
In your method just check if the user is loggedIn, if then abort to 404 like below...
if(IlluminateSupportFacadesAuth::check())
return abort(404);
#Rest of the code is for guest user.....
#
add a comment |
In your method just check if the user is loggedIn, if then abort to 404 like below...
if(IlluminateSupportFacadesAuth::check())
return abort(404);
#Rest of the code is for guest user.....
#
In your method just check if the user is loggedIn, if then abort to 404 like below...
if(IlluminateSupportFacadesAuth::check())
return abort(404);
#Rest of the code is for guest user.....
#
answered Mar 25 at 9:01
AtiqurAtiqur
1,4261621
1,4261621
add a comment |
add a comment |
The guest logic is inside inside AppHttpMiddlewareRedirectIfAuthenticated
.
if (Auth::guard($guard)->check())
abort(404)
return $next($request);
Otherwise, you need to create a new middleware like @Atiqur suggested.
add a comment |
The guest logic is inside inside AppHttpMiddlewareRedirectIfAuthenticated
.
if (Auth::guard($guard)->check())
abort(404)
return $next($request);
Otherwise, you need to create a new middleware like @Atiqur suggested.
add a comment |
The guest logic is inside inside AppHttpMiddlewareRedirectIfAuthenticated
.
if (Auth::guard($guard)->check())
abort(404)
return $next($request);
Otherwise, you need to create a new middleware like @Atiqur suggested.
The guest logic is inside inside AppHttpMiddlewareRedirectIfAuthenticated
.
if (Auth::guard($guard)->check())
abort(404)
return $next($request);
Otherwise, you need to create a new middleware like @Atiqur suggested.
answered Mar 25 at 11:15
sentysenty
4,263859142
4,263859142
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334032%2flaravel-guest-middleware%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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