Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up login view (user authentication) in SPA HotTowel template?

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

like image 346
mitaka Avatar asked Apr 17 '13 15:04

mitaka


2 Answers

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/

like image 87
yagopv Avatar answered Nov 10 '22 12:11

yagopv


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.

like image 4
mitaka Avatar answered Nov 10 '22 13:11

mitaka