aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/login/login.component.ts
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-04-01 07:47:16 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-04-01 07:47:16 -0400
commitd8330f1ac85b26d08ca4df5ce3875078d7b4f47f (patch)
tree2046e58c146097aac21c9e352771420c31df6589 /ufund-ui/src/app/components/login/login.component.ts
parentbc9d3417795d841b4cb3e9fb022f8d61448af946 (diff)
parent233fe120d2a9b30e0150401ebdfeb946dc9c2c07 (diff)
downloadJellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.gz
JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.bz2
JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.zip
Merge branch 'main' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b
Diffstat (limited to 'ufund-ui/src/app/components/login/login.component.ts')
-rw-r--r--ufund-ui/src/app/components/login/login.component.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/ufund-ui/src/app/components/login/login.component.ts b/ufund-ui/src/app/components/login/login.component.ts
index f6a2996..0177f67 100644
--- a/ufund-ui/src/app/components/login/login.component.ts
+++ b/ufund-ui/src/app/components/login/login.component.ts
@@ -1,8 +1,8 @@
import {Component, OnInit} from '@angular/core'
import {UsersService} from '../../services/users.service';
import {ActivatedRoute, Router} from '@angular/router';
-import {BehaviorSubject} from 'rxjs';
import {AuthService} from '../../services/auth.service';
+import {ToastsService, ToastType} from '../../services/toasts.service';
@Component({
selector: 'app-login',
@@ -13,13 +13,13 @@ import {AuthService} from '../../services/auth.service';
export class LoginComponent implements OnInit {
protected next?: string | null;
- protected statusText = new BehaviorSubject("")
constructor(
protected usersService: UsersService,
protected router: Router,
private route: ActivatedRoute,
- private authService: AuthService
+ private authService: AuthService,
+ private toastService: ToastsService
) {}
ngOnInit() {
@@ -35,8 +35,10 @@ export class LoginComponent implements OnInit {
this.authService.login(username, password).then(() => {
this.router.navigate([next]);
+ let key = this.authService.getApiKey()
+ localStorage.setItem("credential", JSON.stringify({username: username, key: key}))
}).catch(ex => {
- this.statusText.next("Unable to login: " + friendlyHttpStatus[ex.status])
+ this.toastService.sendToast(ToastType.ERROR, "Unable to login: " + friendlyHttpStatus[ex.status])
console.log(ex)
})
}
@@ -48,9 +50,9 @@ export class LoginComponent implements OnInit {
}
this.usersService.createUser(username, password).then(() => {
- this.statusText.next("Account created, click login.")
+ this.toastService.sendToast(ToastType.INFO, "Account created, click login.")
}).catch(ex => {
- this.statusText.next("Unable to create account: " + friendlyHttpStatus[ex.status])
+ this.toastService.sendToast(ToastType.ERROR, "Unable to create account: " + friendlyHttpStatus[ex.status])
console.log(ex)
})
}