Hi all.
I put together some authentication stuff and I am certain I didn't do it in the best way possible. I'd love to get some feedback telling me what sucks.
First, a little background:
Server-side, I am using the ServiceStack framework for my REST API, which also handles authentication. Once /auth is successfully called with credentials, ServiceStack sets cookies in the browser so a cached session is used in subsequent calls. ServiceStack can do this out of the box. I also added a /ping service that returns a 401 not authorized if not authenticated. I think I may also add a /userinfo service that returns the logged-in user's information and configuration.
In my main template I have a couple hidden divs to support the login scenario - one to darken the screen and one with a login form, and these are shown when when the interceptor broadcasts an event. I have associated my AuthCtrl with the entire document in the <html> opening tag. The controller stuff is here:
https://gist.github.com/3351232
Feel free to offer any feedback you may have. One thing I am not comfortable with in particular is the manipulation of the DOM from within the controller. Thanks in advance to anyone who feels like checking it out!
Regards,
Cork