aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/app.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/app.component.ts')
-rw-r--r--ufund-ui/src/app/app.component.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/ufund-ui/src/app/app.component.ts b/ufund-ui/src/app/app.component.ts
index 7d9afcd..8068659 100644
--- a/ufund-ui/src/app/app.component.ts
+++ b/ufund-ui/src/app/app.component.ts
@@ -3,6 +3,8 @@ import {BehaviorSubject, Observable} from 'rxjs';
import { DOCUMENT } from '@angular/common';
import {AuthService} from './services/auth.service';
import {ToastType} from './services/toasts.service';
+import {User} from './models/User';
+import {ActivatedRoute, Router} from '@angular/router';
interface ToastProps {
type: ToastType, message: string, action?: {label: string, onAction: () => void}
@@ -16,12 +18,14 @@ interface ToastProps {
})
export class AppComponent implements OnInit {
// title = 'ufund-ui';
- currentUser$: BehaviorSubject<string> = new BehaviorSubject<string>("Logged out.");
+ currentUser?: BehaviorSubject<User | null>;
toast = new BehaviorSubject<ToastProps>({type: ToastType.INFO, message: "testToast"})
constructor(
private authService: AuthService,
+ private router: Router,
+ private route: ActivatedRoute,
@Inject(DOCUMENT) private document: Document
) {}
@@ -30,14 +34,15 @@ export class AppComponent implements OnInit {
}
ngOnInit() {
- this.authService.getCurrentUserSubject().subscribe(r => {
- this.currentUser$?.next(r
- ? "Logged in as " + r.username
- : "Logged out."
- )
- })
+ this.currentUser = this.authService.getCurrentUserSubject()
}
+ login() {
+ this.router.navigate(['/login'], {queryParams: {redir: this.router.url}});
+ }
+ logout() {
+ location.reload()
+ }
}