feat: add dashboard component and routing logic
This commit is contained in:
parent
89083f832f
commit
6bec12b45a
7 changed files with 80 additions and 7 deletions
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue