feat: add dashboard component and routing logic

This commit is contained in:
Jan K9f 2025-01-19 20:46:37 +01:00
commit 6bec12b45a
Signed by: jank
GPG key ID: 50620ADD22CD330B
7 changed files with 80 additions and 7 deletions

View file

@ -13,6 +13,7 @@ import { Router } from '@angular/router';
export class LoginComponent {
public loginForm!: FormGroup;
public invalidCredentials = false;
private pb = new PocketBase(environment.POCKETBASE);
constructor(private router: Router) { };
@ -21,16 +22,18 @@ export class LoginComponent {
email: new FormControl(''),
password: new FormControl(''),
});
if (this.pb.authStore.isValid) {
this.router.navigate(['dashboard']);
}
}
submit() {
const pb = new PocketBase(environment.POCKETBASE);
pb.collection("users").authWithPassword(
this.pb.collection("users").authWithPassword(
this.loginForm.get('email')?.value,
this.loginForm.get('password')?.value
).then(response => {
this.invalidCredentials = false;
).then(() => {
this.router.navigate(['dashboard']);
}).catch(() => {
this.invalidCredentials = true;
});