Login fix and rename columns in DB

This commit is contained in:
2022-12-19 18:36:57 +01:00
parent 120abcaf1d
commit db13b1ab1b
18 changed files with 480 additions and 56 deletions

View File

@@ -1,5 +1,6 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { environment } from 'src/environments/environment';
import { User } from '../models/user.model';
@@ -12,7 +13,7 @@ export class AuthService {
user!: User;
constructor(
private http$: HttpClient
private http$: HttpClient,
) { }
ping() {
@@ -33,20 +34,17 @@ export class AuthService {
getAPIToken(credentials: string): Promise<void> {
return new Promise((resolve, reject) => {
const header = new HttpHeaders().set('Content-type', 'application/json');
this.http$.post<any>(`${environment.api.url}/auth/apiToken`, JSON.stringify(credentials), { headers: header }).subscribe({
this.http$.post<any>(`${environment.api.url}/auth/apiToken`, JSON.stringify(credentials), { headers: header }).subscribe({
next: (data) => {
this.user.id = data.id;
this.apiToken = data.token;
resolve(data);
},
error: (e) => {
console.error('apiToken error', e);
error: (e: HttpErrorResponse) => {
reject(e);
}
}
);
});
//const header = new HttpHeaders().set('Content-type', 'application/json');
//return this.httpClient.post(this.path + "LoginWithGoogle", JSON.stringify(credentials), { headers: header });
}
}