You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
Looking over client/components/auth/auth.service it seems that it would be beneficial for us to use a signature for the methods that would allow for synchronous and async callback/promises.
Its not terribly complicated and I feel provides maximum usability. Such as, all current calls to the auth methods would be maintained sync, we could remove methods such as isLoggedInAsync, and also we could use the promises they return in resolves for routes which could seriously improve the routing authentication.
I'd also like to point out the use of the 2nd argument safe, I've used it to allow us to receive promises that only resolve and not reject. This could be useful in a route resolve as well, being that if a promise is rejected then $routeChangeError or $stateChangeError is fired and we may not always want that.
Another advantage would be that you could chain the promises with finer grained control, dictating whether or not a promise resolves into another (even on error) or is rejected and the chain canceled.
After more investigation, I think that resolves wouldn't (at this time) be suited for authentication in routes. However is still feel that returning promises from the Auth methods would still be beneficial.
@sparqueur check out #465. In auth.service.js the method getCurrentUser is written to be synchronous/asynchronous. When used asynchronously it should provide you with the user object after its resolved.
Activity
kingcody commentedon Aug 16, 2014
With the release of angular 1.3.0 (still beta atm), $q receives some notable upgrades that would allow us to simplify the process even more.
kingcody commentedon Aug 17, 2014
After more investigation, I think that resolves wouldn't (at this time) be suited for authentication in routes. However is still feel that returning promises from the
Authmethods would still be beneficial.Examples:
_Auth.getCurrentUser_
_Auth.isLoggedIn_
_Auth.isAdmin_
Still allows for use as route resolves, and synchronous code by not passing any arguments.
Just some 'opinions'...
DaftMonk commentedon Aug 17, 2014
That looks good. Much cleaner.
kingcody commentedon Aug 17, 2014
@DaftMonk you can checkout this branch if you'd like to see my changes.
sparqueur commentedon Sep 8, 2014
Hi,
Just a little question about the way access the currentUser in a controler safely.
I currently load it in my controler this way :
Unfortunatly sometimes retrieving the user (when refreshing page) takes too much time --> undefined
Workaround for me :
I would prefer accessing currentUser through Auth service (but perhaps I'm just wrong).
Note : I am just trying to enhance my user "settings" page
Thanks in advance
kingcody commentedon Sep 8, 2014
@sparqueur check out #465. In
auth.service.jsthe methodgetCurrentUseris written to be synchronous/asynchronous. When used asynchronously it should provide you with the user object after its resolved.sparqueur commentedon Sep 8, 2014
Ho, sorry. Think I was a little tired...
Thanks for this cool generator which made me win a lot of time.
kingcody commentedon Sep 8, 2014
@sparqueur no problem. Hope that helps you out 😄
feat(app-auth): Improve client-side Auth service
kingcody commentedon Oct 1, 2014
Closed by #465