witoldsz / angular-http-auth

MIT License
2.38k stars 417 forks source link

How to add Token in every request #80

Closed farvashani closed 9 years ago

farvashani commented 9 years ago

Dear Friends. I did my research but i did not find any solution to add the token if it is already exist. I know that the updater is supposed to add the token to header after s successful log-in but what about a case when user is already logged in and has a valid token? there should be a function to add the token to any request if the token is available.

is there anything that I am missing here? I suggest a request function to the interceptors to add the header. is there any similar functionality that i am not aware of?

witoldsz commented 9 years ago

Yes, you can create and register an $http interceptor which will add something to each outgoing request if user is logged in, can you not?

farvashani commented 9 years ago

Yes, I can do that. but I was hoping for existing solution in the code.

witoldsz commented 9 years ago

That's surprising. What kind of token are we talking about?

farvashani commented 9 years ago

the base-64 encoded token that server is generating after user logged in or anything similar to that.? I have created a interceptor with request function. I think its better to have it in core system.

jimx6 commented 9 years ago

WSSE for example..

witoldsz commented 9 years ago

How is that different from cookies? 20 wrz 2014 14:47 "farvashani" notifications@github.com napisał(a):

the base-64 encoded token that server is generating after user logged in or anything similar to that.? I have created a interceptor with request function. I think its better to have it in core system.

— Reply to this email directly or view it on GitHub https://github.com/witoldsz/angular-http-auth/issues/80#issuecomment-56266938 .

farvashani commented 9 years ago

Cookies are Automatically added to any request by browser. but token has to be added by custom code.

In Addition when we create a service with a separated frond-end using the cookie would be tricky. as service and the actual UI are loading from different Domain.( a PhoneGap App which using a Service).

so all I am saying is it would be nice if the core Code has some place to add the token in the user is already Logged in.

witoldsz commented 9 years ago

As you said, the token has to be added by a custom code. This is what $http interceptors are for.

I can see no place for such a custom requirement in a generic module like this one. From time to time someone comes here and ask for some very specific requirement.

Look at #78 as an example. If I was to accept such stuff, this module would become a big ball of mud.

What do you think?

farvashani commented 9 years ago

Well, I am agree with you. Thanks for you great library..

eddiemonge commented 9 years ago

So this can be closed then?