Use the Redirect Routes

From @jayair on Mon Apr 10 2017 01:08:17 GMT+0000 (UTC)

Link to chapter - http://serverless-stack.com/chapters/use-the-redirect-routes.html

Copied from original issue: https://github.com/AnomalyInnovations/serverless-stack-com/issues/59

From @walshe on Wed Jan 24 2018 22:39:12 GMT+0000 (UTC)

If I want one or more special admin users of the app. How is the best way to handle this a) on the Cognito side and b) on the client side

Unsure if its IAM roles I should be using or the Groups facility in Cognito.

i.e. when a regular user signs up I would like them to have a ā€˜APP_USERā€™ role or something that I can also get from the currentUser variable on the frontend side (so that I can render correct menus etc)

I guess I could role my own sort of approach but surely theres some way of doing this with cognito ?

From @jayair on Fri Jan 26 2018 01:06:28 GMT+0000 (UTC)

@walshe Yeah as I was saying in the other thread, Iā€™m not sure if there is a built-in way to do this.

From @DavidNaMills on Tue Mar 13 2018 13:22:52 GMT+0000 (UTC)

iā€™m getting the most insane result from this chapter:
I was testing the redirect function when everything went wrong.
Trying to access ā€œlocalhost:3000/notes/newā€ when not logged in.
I get the following error message:
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

and the URL looks like this:

http://localhost:3000/notes/login?redirect=/notes/login%20?redirect=/notes/login%20?redirect=/notes/login%20?redirect=/notes/login%20?redirect=/notes/login%20?redirect=/notes/login%20?redirect=/notes/login%20?redirect=/notes/login%20?
(I deleted about 20 lines for the sake of length)

The error is pointing at:

G:/aws_tutorial/react_front/notes-app-client/src/App.js:33

> 33 |   this.setState({isAuthenticating:false});

Any ideas?

From @walshe on Tue Mar 13 2018 13:26:40 GMT+0000 (UTC)

only call setState from somewhere that is handling an event

From @jayair on Tue Mar 13 2018 17:47:20 GMT+0000 (UTC)

@DavidNaMills It looks like it caught in some sort of a loop, where it is redirecting back to itself?

Something similar happened to me. In my case that was due to a typo in AuthenticatedRoute.js. Specifically, I produced an error in the <Redirect to /> component, i.e. missing a slash at the beginning of the URL.

1 Like

You may have missed a slash. Can you post your code here?