How can I pass the referrer url before the Auth component redirect me to the login page?
Currently I'm using this method to redirect user to the previous page after logging in
$this->Auth->redirect()
However, in my case sometimes that redirects me to the wrong location. (i.e I think in my case /users gets called along the way and it will redirect me to that location instead of where they came from). So I'm trying to see if passing the referrer url will help.
Thank you,
Tee
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html
Hope this will give a solution for you doubt
$this->redirect($this->Auth->redirect());
worked for me.
After logging in, it goes to the page that I attempted while logged out.
Related
I'm not sure what the "next.js" way would be in this case.
What I'm trying to accomplish: read a cookie, see if there is a "JWT" cookie, and either display a login form or redirect to a page with a login form.
What would be the Next.js way of doing this? I would prefer to redirect to a page that has a login form on it, or is this not possible?
I wasn't able to find any information on dynamic redirects for next.js
I already posted the answer yesterday to your other question
ctx.res.writeHead(302, { Location: "/login" });
see the full post here: https://stackoverflow.com/a/64421136/4632620
If you'd like to programmatically redirect or change the URL in Nextjs, you use the router: https://nextjs.org/docs/api-reference/next/router#routerpush
I have an AngularJs UI login page and I'm posting the username and password details to a Servlet to validate, and when I'm returning back I'm using sendRedirect from Servlet but it's not working. Here is my sample code
In Servlet:
req.sendRedirect("NewFile.jsp");
It is displaying content inside NewFile.jsp within the login page itself instead of redirecting to NewFile.jsp
I have tried using "$window.location.href" inside AngularJs code but that itself didnt forward to home page.
Any help is much appreciated.
Thank you!
Acording of what you said in the comment of the bounty, I have to say that having everything in only one controller sounds like a bad idea, for more information about this and naming conventions go to Naming conventions and best practices
According to your question, maybe you need to give more details of the problem, it's not clear.
Have you tried to use $location module?
https://docs.angularjs.org/api/ng/service/$location
You can use de .path() module to redirect.
$location.path('#!/');
That will redirect you to the home page.
I'm trying to setup and 404 page on my website by using
$urlRouterProvider.otherwise("/404");
but this only works for URLs that do not have multiple slashes/parameters. The following is all of my URLs and states in the same order as in my code:
Home – /
404 – /404
About – /about-us
Privacy – /privacy-policy
Terms – /terms-conditions
Subscribe – /subscribe
Author – /author/:author
Topic – /:category/page/:pageNumber
Post – /:category/:title
If there is a url with two slashes (Ex: /qwkhdjqkwnd/q1weuih), my app thinks it's a Post and tries to fetch information but this obviously fails – it does not know that this is not a valid URL, and thus does not redirect to my 404 page.
What's the best practice for this? Should I allow the app to try and fetch data using the invalid URL and, redirect the state when it fails?
Checking for an undefined object and redirecting to /404 worked for my purposes.
My use case is very simple and i'm sure many apps share the same one. I need to verify user and need a simple url to retrieve user token from URL, make api call to my backend service and route the user according to the result from the API.
I don't need to render any page but just make API call and parse the response. I see two options to accomplish: Resolve or OnEnter. I also think there might be another simple way.
Here are the steps:
user getting email with link to /verify?token={token}
in app.js I have a state 'verify' and URL '/verify=token'
call API and get "true" or "false"
if false, redirect user to homepage, if true redirect the user the user profile page.
What is the best and simple way to accomplish what I like to do?
Thanks.
btw - I'm using ui-router.
In your case, I think you should use Resolve of ui-router to make sure state won't load until all data were resolved.
To make user feel good, you should show a loading indicator and register event $stateChangeSuccess to hide it once done
I have build an AngularJS application and want to use paymill.com to offer different payment methods. I am currently struggling with PayPal.
This api-call allows me to specify a redirect url where the customer gets redirected to after the payment:
https://developers.paymill.com/API/index#create-new-payment-checksum
I get a response with this URL as 'return_url':
http%3A%2F%2Ftest.test.com%2F%23%2Fteatimes%2Fbuy%2Fp82uHoLI6z%2F1
which seems to be the correct encoding for:
http://test.test.com/#/teatimes/buy/p82uHoLI6z/1
Sadly the redirect after the payment does not work and simply redirects me to:http://test.test.com/?paypal_parameters/#/.
So it seems like that everything after the hashtag gets ommited...Is there a way to fix this on my end? I would rather not use html5 mode.
EDIT: If i use the above url without the '#' i get correctly redirect, but angularjs is unable to resolve this of course.
Why don´t you wanna use the html5 mode? you wouldn´t have any issue with the hashtag.
What angular method do you use for redirecting to the URL.