# How to implement on-the-fly authentication?

**URL:** <https://community.auth0.com/t/how-to-implement-on-the-fly-authentication/8100>\
**Category:** Get Help\
**Tags:** angular4, on-the-fly, protected, routerlink, authentication\
**Created:** [September 6, 2017, 2:51am UTC](https://community.auth0.com/t/how-to-implement-on-the-fly-authentication/8100 "2017-09-06T02:51:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsq125](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hsq125/32/12460_2.png) [@hsq125](https://community.auth0.com/u/hsq125)\
**Post date:** [September 6, 2017, 2:51am UTC](https://community.auth0.com/t/how-to-implement-on-the-fly-authentication/8100/1 "2017-09-06T02:51:53Z")

</div>

Hi all,

- I’m creating a SPA with Angular 4
- My use case: pretty simple. I have button that brings the user to a page (via routerLink). The user must be authenticated to access the page. Flow must be as follow: (1) If the user is already authenticated when he clicks on the button, the protected page must be displayed. (2) If not authenticated when clicking on the button, the login prompt must be displayed, and after successful authentication, the protected page must be displayed.
- my route is dynamic (e.g.: /register/234) → I cannot have a fixed callback URL

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/how-to-implement-on-the-fly-authentication/8100/2 "2018-03-02T05:56:20Z")

</div>


