Backend authentication

This commit is contained in:
2022-12-09 00:14:05 +01:00
parent 81b5f323eb
commit a2c90f80d5
8 changed files with 83 additions and 60 deletions

View File

@@ -15,10 +15,9 @@ export class AuthService {
private http$: HttpClient
) { }
loadDbUser() {
ping() {
return new Promise((resolve, reject) => {
const headers = new HttpHeaders({
// 'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiToken}`
})
this.http$.get<any>(`${environment.api.url}/ping/ping`, {
@@ -43,7 +42,7 @@ export class AuthService {
const header = new HttpHeaders().set('Content-type', 'application/json');
this.http$.post<any>(`${environment.api.url}/auth/apiToken`, JSON.stringify(credentials), { headers: header }).subscribe({
next: (data) => {
console.log('apiToken', data);
if (this.user) { this.user.id = data.id }
this.apiToken = data.token;
resolve(data);
},