Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login(username: string, password: string) {
- const body = {username: username, password: password};
- return this.http.post<AuthResponse>(`${this.baseUrl}`, body, { observe: 'response' })
- .subscribe(response => {
- const user = response.body;
- if (user && user.token) {
- localStorage.setItem(this.localStorageKey, JSON.stringify(user));
- return true;
- }
- localStorage.removeItem(this.localStorageKey);
- return false;
- });
- }
Add Comment
Please, Sign In to add comment