Skip to content

Commit

Permalink
fix(auth): fix unable attach token in url
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Apr 8, 2018
1 parent 1bf64c6 commit ac6c3f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 14 additions & 1 deletion packages/auth/token/simple/simple.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,20 @@ describe('auth: simple.interceptor', () => {
done();
});
const req = httpBed.expectOne(() => true) as TestRequest;
expect(req.request.url).toBe('/test?token=123');
expect(req.request.params.has('token')).toBe(true);
expect(req.request.params.get('token')).toBe('123');
req.flush('ok!');
});
it(`in url via full-domain`, (done: () => void) => {
genModule({
token_send_place: 'url'
}, genModel('123'));
http.get('https://ng-alain.com/test', { responseType: 'text' }).subscribe(value => {
done();
});
const req = httpBed.expectOne(() => true) as TestRequest;
expect(req.request.params.has('token')).toBe(true);
expect(req.request.params.get('token')).toBe('123');
req.flush('ok!');
});
});
Expand Down
4 changes: 1 addition & 3 deletions packages/auth/token/simple/simple.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ export class SimpleInterceptor extends BaseInterceptor {
});
break;
case 'url':
const url = this.injector.get(Router).parseUrl(req.url);
url.queryParams[options.token_send_key] = token;
req = req.clone({
url: url.toString()
params: req.params.append(options.token_send_key, token)
});
break;
}
Expand Down

0 comments on commit ac6c3f7

Please sign in to comment.