Satellizer isn't sending Authentication headers with some clients

124 Views Asked by At

Similar to this question. But OP stated that his problem solved "on its own".

Also similar to this.

(I'm going to copy paste some parts of the descriptions since it's pretty much the same problem)

I am working on a project using angularjs/laravel. It's a token based project so I am using satellizer to handle that.

One of our clients has the problem of not being able to login, it's not only not working on his browser... it doesn't even work if he creates a new user account in his computer.

The problem is that it's not sending an Authorization Token to the server, a valid Token is being stored in the local session, but it's not being sent in the headers. Also I can't set the headers manually.

When looking at the request headers in the network tab in dev tools I can see that the request does not contain the authorization header.

I'm lost on what to do since I feel like I tried everything I could. Tried to clean cache and delete cookies. Checked if cookies were blocked (they weren't). Checked for weird antivirus, firewalls or weird programs installed (nothing). I also tried restarting the system and creating a new user account for the same computer, nothing worked.

It actually works in every other client's pc, except last year something similar happened to another client (same project) and we blamed it on his old OS not supporting something from satellizer, but this time it's a last gen pc. Also it used to work and stopped working with his pc suddenly. (after running ccleaner maybe).

My suspicion is that it isn't really something to do with his computer, but a weird bug in satellizer that triggers with some tricky conditions.

I hope that someone knows at least where I could start looking for answers to this problem.

Also it's the first time I post a question here...(feeling shy), hi. (help)

1

There are 1 best solutions below

0
Carl Kroeger Ihl On

I still don't know the reason why this happened to begin with.

In the end I solved it by editing part of satellizer source code.

if (_this.SatellizerShared.isAuthenticated() && _this.SatellizerConfig.httpInterceptor()) {
                    var tokenName = _this.SatellizerConfig.tokenPrefix ?
                        [_this.SatellizerConfig.tokenPrefix, _this.SatellizerConfig.tokenName].join('_') : _this.SatellizerConfig.tokenName;
                    var token = _this.SatellizerStorage.get(tokenName);
                    if (_this.SatellizerConfig.tokenHeader && _this.SatellizerConfig.tokenType) {
                        token = _this.SatellizerConfig.tokenType + ' ' + token;
                    }
                    config.headers[_this.SatellizerConfig.tokenHeader] = token;
                }

Satellizer wasn't setting the header, so I added: config.headers[_this.SatellizerConfig.tokenHeader] = token; outside of the if and satellizer was able to set the header correctly.

After that I undid my changes to see if after setting the headers correctly satellizer would work as expected and it worked, so for some reason it wasn't able to recognize my authenticated user and left the headers out making it fail. But after forcing it to add the headers once it worked fine everytime afterwards.

Hope this can help somebody struggling with a similar issue.