Guest User

Untitled

a guest
Oct 30th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. login(username: string, password: string) {
  2. const body = {username: username, password: password};
  3. return this.http.post<AuthResponse>(`${this.baseUrl}`, body, { observe: 'response' })
  4. .subscribe(response => {
  5. const user = response.body;
  6. if (user && user.token) {
  7. localStorage.setItem(this.localStorageKey, JSON.stringify(user));
  8. return true;
  9. }
  10.  
  11. localStorage.removeItem(this.localStorageKey);
  12. return false;
  13. });
  14. }
Add Comment
Please, Sign In to add comment