rdt-client/client/src/app/auth.service.ts

39 lines
1,008 B
TypeScript

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
@Injectable({
providedIn: 'root',
})
export class AuthService {
constructor(private http: HttpClient) {}
public isLoggedIn(): Observable<void> {
return this.http.get<void>(`/Api/Authentication/IsLoggedIn`);
}
public create(userName: string, password: string): Observable<void> {
return this.http.post<void>(`/Api/Authentication/Create`, {
userName,
password,
});
}
public login(userName: string, password: string): Observable<void> {
return this.http.post<void>(`/Api/Authentication/Login`, {
userName,
password,
});
}
public logout() {
return this.http.post<void>(`/Api/Authentication/Logout`, {});
}
public update(userName: string, password: string): Observable<void> {
return this.http.post<void>(`/Api/Authentication/Update`, {
userName,
password,
});
}
}