Hi,
I had the same issue. I could not find a nice solution, so I worked it
around. It is not very pretty, but works and I am eager to hear about
alternate solutions :)
OK, so here is the implementation:
https://gist.github.com/3111582
(see lines #14 and #16)
I wanted to create a new blog entry describing my implementation, but
did not manage to do it yet. My goal is to demonstrate it as a
separate module, so applications can use it just by declaring
dependency on "angular-auth" module.
Comments, suggestions are welcome :)
Regards,
Witold Szczerba
On 14 July 2012 01:30, Brice Burgess <
bric...@gmail.com> wrote:
> I am following the patterns outlined by Witold Szczerba in
>
http://www.espeo.pl/2012/02/26/authentication-in-angularjs-application to
> provide an authorization layer to my application -- although am refactoring
> to use services in an attempt to keep the rootScope clean and to learn more
> about Angular! ;)
>
> After many hours spent in an extreme fight to push a .service() derived
> interceptor to $httpProvider, I had to relent and create a .factory()
> provided one. (for the curious; I was trying to do something like
> `$httpProvider.responseInterceptors.push(AuthenticationService.interceptor);`).
> So I have 2 services;
>
> 1. AuthenticationService (depends on $http)
> 2. AuthenticationInterceptor (depends on $q, AuthenticationService)
>
> When I add the $http dependency to the Authentication service, I get:
>
> Circular dependency: AuthenticationService <- AuthenticationInterceptor <-
> $http
>
> My initial thought is that this involves $q in the Interceptor -- but I'm
> unsure && don't easily see the circle.
>
> A jsFiddle is up @
>
http://jsfiddle.net/rBZkE/
>
> If anyone has the time to look at this & comment, please consider yourself a
> saint. I'm also curious as to feedback re: using this strategy for
> implementing an authorization layer. It seems a hot topic!
>
> Many thanks,
>
> ~ Brice
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/angular/-/ryTHk37KYTUJ.
> To post to this group, send email to
ang...@googlegroups.com.
> To unsubscribe from this group, send email to
>
angular+u...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/angular?hl=en.