Using angularjs + ui router
Three abstract states:
- Welcome (static home page)
- Unlogged (login, logout, register)
- Logged (application)
Pushing a "login" button inside Welcome will redirect to Unlogged.login. Unlogged.login will check username/password and save them to cookie (at each try, even if it fails).
- ui router module injected to your app
- There is an injectable logger
- Ui router will resolve a user object inside Logged parent route.
- This user object has a "set" method to save last form data inside a cookie and use them
- This user object has a "logIn" method to check the cookie
- Logged parent defines a "$state.permissions" to specify if a route requires login and admin privileges
- Login function inside a login controller used by Unlogged.login
- A check for logged cookie inside the ui router resolver of the main Logged abstract state
- A check at every route change, via ui router broadcast interception
- A timeout to check every minute if the actual cookie is authorized
This last step is under development...