Vorbereitung Release 0.2.0 #83
@@ -1,6 +1,5 @@
|
|||||||
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
|
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
|
||||||
import { provideRouter, withComponentInputBinding } from '@angular/router';
|
import { provideRouter, withComponentInputBinding } from '@angular/router';
|
||||||
|
|
||||||
import { routes } from './app.routes';
|
import { routes } from './app.routes';
|
||||||
import { provideHttpClient } from '@angular/common/http';
|
import { provideHttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { catchError, throwError } from 'rxjs';
|
import { catchError, Observable, throwError } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
interface AuthResponseData {
|
interface AuthResponseData {
|
||||||
@@ -16,13 +16,9 @@ export interface TokenData {
|
|||||||
token_type: string;
|
token_type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({providedIn: 'root'})
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
constructor(private http: HttpClient) {
|
private http = inject(HttpClient);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
signup(email: string, password: string) {
|
signup(email: string, password: string) {
|
||||||
return this.http.post<TokenData>('http://localhost:8800/signup',
|
return this.http.post<TokenData>('http://localhost:8800/signup',
|
||||||
@@ -44,11 +40,15 @@ export class AuthService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
login(email: string, password: string) {
|
login(email: string, password: string): Observable<TokenData> {
|
||||||
return this.http.post<TokenData>('http://127.0.0.1:8800/api/login/token',
|
const params = new HttpParams()
|
||||||
|
.set('username', email)
|
||||||
|
.append('password', password);
|
||||||
|
return this.http.post<TokenData>('http://127.0.0.1:8800/api/login/token', params,
|
||||||
{
|
{
|
||||||
username: email,
|
headers: {
|
||||||
password: password
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,16 +39,16 @@ export class Auth {
|
|||||||
authObservable = this.authService.signup(email, password)
|
authObservable = this.authService.signup(email, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
authObservable.subscribe(
|
authObservable.subscribe({
|
||||||
token => {
|
next: token => {
|
||||||
console.log(token);
|
console.log(token);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
},
|
},
|
||||||
(err: HttpErrorResponse) => {
|
error: err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
form.reset();
|
form.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user