Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(github): add github token function
Browse files Browse the repository at this point in the history
  • Loading branch information
dgutride authored and joshuawilson committed Dec 13, 2017
1 parent 7b4522c commit eef66a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/auth/authentication.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,30 @@ describe('Service: Authentication service', () => {
// token should be empty after token is cleared
expect(output).toBe('');
expect(localStorage.getItem('github_token')).toBeNull();
expect(authenticationService.getGitHubToken()).toBeNull();
authenticationService.logout();
done();
});
});

it('Github token processing', (done) => {
// given
mockService.connections.subscribe((connection: any) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: tokenJson,
status: 201
})
));
});
spyOn(authenticationService, 'setupRefreshTimer');

broadcaster.on('loggedin').subscribe((data: number) => {
let token = JSON.parse(tokenJson);
expect(authenticationService.getGitHubToken()).toBe(token.access_token);
done();
});

authenticationService.logIn(tokenJson);
});
});
4 changes: 4 additions & 0 deletions src/app/auth/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export class AuthenticationService {
return token;
}

getGitHubToken(): string {
return localStorage.getItem(this.github + '_token');
}

clearGitHubToken(): void {
localStorage.removeItem(this.github + '_token');
this.gitHubToken = Observable.of('');
Expand Down

0 comments on commit eef66a8

Please sign in to comment.