Some of the Single Page Application (SPA) templates in VS2012 MVC4 have built-in authentication. HotTowel SPA Template does not.
What is the proper way to implement user authentication (login screen) in SPA HotTowel? HotTowel uses Durandal JS, so I guess the question is really how to implement user authentication with Durandal JS
I created a starter template with authentication and authorization included
Perhaps could help ...
Github => https://github.com/yagopv/durandalauth
Sample site => https://durandalauth.azurewebsites.net/
Looks like the Durandal JS Google group have some answers but not concrete sample code.
Authentication with Durandal
Looking to add authentication to the SPA sample, but keep it an SPA
Mauro Servienti ideas:
My backend exposes a service (WebAPI in my case) where there is an operation getCurrentUser.
So, in my main.js, in the app.Start() then callback before calling app.setRoot I issue a call the backend asking, async, for the user if the result is a valid user I set the root to the main app shell otherwise I set the root to the login shell.
What is the problem? From the client side point of view the authentication is just a “flag” that says: ok, I know who you are. You can leverage the power of the FormsAuthentication and live with that, then expose a WebAPI GET action that let you retrieve info about the currently logged user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With