Reworked login system + added substitution page
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Userdata} from "../entities/userdata";
|
||||
import {Userdata, AuthKeys} from "../entities/userdata";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
@@ -20,17 +20,14 @@ export class IServService {
|
||||
|
||||
public async login(email: string, password: string): Promise<boolean> {
|
||||
const split = email.split('@');
|
||||
this.userdata = {};
|
||||
this.userdata.username = split[0];
|
||||
this.userdata.domain = split[1];
|
||||
this.userdata.password = password;
|
||||
|
||||
const data = new FormData();
|
||||
data.append("email", email);
|
||||
data.append("password", password);
|
||||
this.userdata = {
|
||||
username: split[0],
|
||||
domain: split[1],
|
||||
password
|
||||
};
|
||||
|
||||
try {
|
||||
this.userdata.token = await firstValueFrom(this.client.post(`${this.backend}/login`, data, {responseType: "text"}));
|
||||
await firstValueFrom(this.client.post(this.backend + "/auth/login", this.userdata));
|
||||
localStorage.setItem("userdata", JSON.stringify(this.userdata));
|
||||
return true;
|
||||
}catch (error) {
|
||||
@@ -38,4 +35,8 @@ export class IServService {
|
||||
}
|
||||
}
|
||||
|
||||
public async getKeys(): Promise<AuthKeys> {
|
||||
return await firstValueFrom(this.client.post<AuthKeys>(this.backend + "/auth/login", this.userdata));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user