# Prompt User to Sign In to Authenticate

**URL:** <https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 9, 2023, 1:10pm UTC](https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468 "2023-05-09T13:10:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![msitson](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@msitson](https://forum.inductiveautomation.com/u/msitson)\
**Post date:** [May 9, 2023, 1:10pm UTC](https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468/1 "2023-05-09T13:10:01Z")

</div>

Hello,

I would like to prompt the user to login when a certain view is opened. I have tried to use the login event on view start up and system.perspective.login in a startup script. However, after the user has logged in it does not send the user to the view, but loads the sign in page again for the user to sign in.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 9, 2023, 1:54pm UTC](https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468/2 "2023-05-09T13:54:03Z")

</div>

Two things:

- When the view opens is generally too late. When about to open the view is generally the right time.

- Use [system.perspective.authenticationChallenge()](https://docs.inductiveautomation.com/display/DOC81/system.perspective.authenticationChallenge) **before** opening the view.

---

<div class="post-metadata">

**Author:** ![msitson](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@msitson](https://forum.inductiveautomation.com/u/msitson)\
**Post date:** [May 9, 2023, 2:28pm UTC](https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468/3 "2023-05-09T14:28:06Z")

</div>

I tried placing system.perspective.authenticationChallenge() before my navigate. Although it sends me to the page now, it says that access is denied. It appears that the user is not logged in after the page is loaded.

---

<div class="post-metadata">

**Author:** ![msitson](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@msitson](https://forum.inductiveautomation.com/u/msitson)\
**Post date:** [May 9, 2023, 2:30pm UTC](https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468/4 "2023-05-09T14:30:53Z")

</div>

My apologies it was the way I worded my question. I replaced authenticationChallenge with login and it works as intended. Thank you for the help.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 9, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/prompt-user-to-sign-in-to-authenticate/73468/5 "2023-05-09T14:47:56Z")

</div>

Consider checking whether they are logged in and using `.login()` or `.authenticationChallenge` as needed.
