# Redirect on Login

**URL:** <https://discourse.sst.dev/t/redirect-on-login/24>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 6:39pm UTC](https://discourse.sst.dev/t/redirect-on-login/24 "2018-05-09T18:39:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 6:39pm UTC](https://discourse.sst.dev/t/redirect-on-login/24/1 "2018-05-09T18:39:07Z")

</div>

_From @jayair on Mon Apr 10 2017 01:08:29 GMT+0000 (UTC)_  
  
Link to chapter - [http://serverless-stack.com/chapters/redirect-on-login.html](http://serverless-stack.com/chapters/redirect-on-login.html)  
  
_Copied from original issue: [https://github.com/AnomalyInnovations/serverless-stack-com/issues/60](https://github.com/AnomalyInnovations/serverless-stack-com/issues/60)_

---

<div class="post-metadata">

**Author:** ![sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@sam](https://discourse.sst.dev/u/sam)\
**Post date:** [December 6, 2018, 1:10am UTC](https://discourse.sst.dev/t/redirect-on-login/24/2 "2018-12-06T01:10:28Z")

</div>

Getting this warning, and I don’t see any async in UnathenticatedRoute

```
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in Login (at UnauthenticatedRoute.js:27)
```

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [December 7, 2018, 12:12am UTC](https://discourse.sst.dev/t/redirect-on-login/24/3 "2018-12-07T00:12:36Z")

</div>

This means that there is a `setState` getting called after the component has been unmounted. On which step of the chapter are you seeing this?

---

<div class="post-metadata">

**Author:** ![sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@sam](https://discourse.sst.dev/u/sam)\
**Post date:** [December 7, 2018, 10:09pm UTC](https://discourse.sst.dev/t/redirect-on-login/24/4 "2018-12-07T22:09:55Z")

</div>

I’ve implemented the “Redirect on login” code… I get that warning when I log in (from logged out state). Enter email/password, click log in, spins while loading, and then I get that warning right before it navigates home.

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [December 9, 2018, 7:56pm UTC](https://discourse.sst.dev/t/redirect-on-login/24/5 "2018-12-09T19:56:32Z")

</div>

Did you remove this line as it talks about in the chapter?

```auto
this.props.history.push("/");

```

---

<div class="post-metadata">

**Author:** ![CSSian](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@CSSian](https://discourse.sst.dev/u/CSSian)\
**Post date:** [January 30, 2019, 4:47am UTC](https://discourse.sst.dev/t/redirect-on-login/24/6 "2019-01-30T04:47:36Z")

</div>

This statement, IMHO, is misleading:

> Now let’s update our _Redirect_ component to use this when it redirects.

True, **Redirect** is a component, but it’s not “our’s”, it’s from **react-router-dom**. And true, it is that component’s code that must be modified, but wouldn’t it be clearer to direct the reader to “our” component, **UnauthenticatedRoute** , which includes **Redirect**?

Thanks for considering.

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [January 30, 2019, 12:03pm UTC](https://discourse.sst.dev/t/redirect-on-login/24/7 "2019-01-30T12:03:59Z")

</div>

Thanks for the heads up. Edited that line a bit.

---

<div class="post-metadata">

**Author:** ![mjensen6](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/mjensen6/32/1033_2.png) [@mjensen6](https://discourse.sst.dev/u/mjensen6)\
**Post date:** [December 15, 2020, 4:52pm UTC](https://discourse.sst.dev/t/redirect-on-login/24/8 "2020-12-15T16:52:45Z")

</div>

If I try to access a noteId without being logged in I get successfully sent to the login page with the redirect link. However, I am then able to login as any user and see the note. Is this an error on my end, or just something not covered in this tutorial? I understand it’s a demo and not every little security hole needs to be patched up, just want to make sure I didn’t miss anything on my end.

Love the tutorial, it has taught me so much. Thank you for putting your time and effort in to this great resource!

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [January 3, 2021, 12:49am UTC](https://discourse.sst.dev/t/redirect-on-login/24/9 "2021-01-03T00:49:37Z")

</div>

No that shouldn’t happen. Can you try this on the hosted demo:

> **[Scratch - A simple note taking app](https://demo2.serverless-stack.com)**
