Hi group!

I'm developing an Angular web app with the following requirement:

   1. Users should be able to create an account and login.
   2. Angular UI-Router.
   3. The session is built with JSON Web Token.
   4. Language support. An authenticated user should always get his/her 
   preferred language (from the account) if an URL is accessed without 
   language prefix.
   5. Unmatched URLs should be tested with language prefix before we treat 
   them as "wrong".
   6. An interceptor that add JWT functionality to all API requests.
   
We need an architecture like this:

   1. Request to the server (determine if the user is authenticated or not)
   2. If the user is authenticated check the entered URL.
   3. If the user is anonymous check the entered URL.
   4. The entered URL is checked; no language prefix was provided, retrieve 
   the prefix from the user account (if authenticated) or ask the backend for 
   which language the anonymous user should have.
   5. Check is the entered URL has a valid state (with the retrieved 
   language prefix). In this case, "redirect" the user to the "right" URL 
   (including language prefix).
   6. If the entered URL does not match any state, redirect the user to a 
   default front page, based on the user status (anonymous or authenticated).

Our architecture so far:

   - We have solved the language architecture with an abstract state that 
   handles language prefix. So all the other states are children to that. For 
   example "/login" has the state "app.login" where "app" is the abstract 
   state. The language prefixes works has expected.
   - When the "app" state is triggered, we have a "resolve" that initiates 
   the user object and there try to determine if the user is anonymous or 
   authenticated.
   - Inside $urlRouterProvider.otherwise() we call for the user initiation 
   function as well, to determine the current user.
   
Our problems:

   - The user initiation logic does not work as expected.
   - We don't know how to "think" to create such architecture.
   - Because thinks happen asynchronous, it seems to be difficult to make 
   stuff happen i "right order".
   

I understand that it's very difficult to answer with some code example. 
What I need help with is a "thinking" about how to solve this architecture, 
not code itself.

Thank you very much for all help I can get!




-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to