Developer 02 b6cdb80162 Revert "fix: Vorübergehend nur Dark Mode erlaubt wegen localStorage Problem"
This reverts commit fb0e719616d0aac846b9243aa9946d6cd942723f.
2024-07-25 12:52:45 +02:00

51 lines
1.4 KiB
TypeScript

import { Component, Inject, Input } from '@angular/core';
import { AuthenticationService } from '../services/authentication.service';
import Swal from 'sweetalert2';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
@Component({
standalone: true,
imports: [CommonModule, FormsModule],
selector: 'app-login',
templateUrl: './login.component.html',
styleUrl: './login.component.css'
})
export class LoginComponent {
username: string = '';
password: string = '';
waitRes: boolean = false;
IsPwdHidden: boolean = true;
constructor(private authService: AuthenticationService, @Inject(MAT_DIALOG_DATA) public data: any) {
//localStorage.getItem('theme') === 'dark'
if (typeof (this.afterLogin) == typeof (data.afterLogin))
this.afterLogin = data.afterLogin;
}
@Input() afterLogin: () => void = () => { }
login(): void {
this.waitRes = true;
this.authService.login(this.username, this.password).subscribe({
next: () => this.afterLogin(),
error: (err) => {
this.waitRes = false;
Swal.fire({
icon: "error",
title: "Oops...",
text: err.error.messages.join("\n"),
});
},
complete: () => this.waitRes = false
})
}
onPasswordEyeClicked() {
this.IsPwdHidden = !this.IsPwdHidden;
}
}