diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8fc7358..75eeea8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -36,12 +36,13 @@ export class AppComponent { if (this.cookieService.check('Authorization')) { this.twigsService.getProfile().subscribe(user => { this.user.next(user); - if (this.activatedRoute.pathFromRoot.length == 0) { - this.router.navigateByUrl("/budgets") + if (this.activatedRoute.snapshot.url.length == 0) { + this.router.navigateByUrl("/budgets"); } }); - } else { - this.router.navigateByUrl("/login") + } else if (this.activatedRoute.snapshot.url.length > 0) { + console.log(this.activatedRoute.snapshot.url) + this.router.navigateByUrl("/login"); } updates.available.subscribe( @@ -91,6 +92,7 @@ export class AppComponent { logout(): void { this.twigsService.logout().subscribe(_ => { this.location.go('/'); + window.location.reload(); }); } diff --git a/src/app/budgets/budget.component.css b/src/app/budgets/budget.component.css index 25aa3dd..41ad360 100644 --- a/src/app/budgets/budget.component.css +++ b/src/app/budgets/budget.component.css @@ -1,5 +1,4 @@ .dashboard { - color: #F1F1F1; display: flex; flex-wrap: wrap; align-items: center; diff --git a/src/app/budgets/budget.component.ts b/src/app/budgets/budget.component.ts index 54bf813..53c33f6 100644 --- a/src/app/budgets/budget.component.ts +++ b/src/app/budgets/budget.component.ts @@ -16,19 +16,20 @@ export class BudgetsComponent implements OnInit { constructor( private app: AppComponent, - @Inject(TWIGS_SERVICE) private twigsService: TwigsService, + @Inject(TWIGS_SERVICE) private twigsService: TwigsService, ) { } ngOnInit() { this.app.setBackEnabled(false); - this.app.setTitle('Budgets') this.app.user.subscribe( user => { if (!user) { this.loading = false; this.loggedIn = false; + this.app.setTitle('Welcome') return; } + this.app.setTitle('Budgets') this.loggedIn = true; this.loading = true; this.twigsService.getBudgets().subscribe( diff --git a/src/app/shared/twigs.http.service.ts b/src/app/shared/twigs.http.service.ts index 8d0fc4f..0da3969 100644 --- a/src/app/shared/twigs.http.service.ts +++ b/src/app/shared/twigs.http.service.ts @@ -48,7 +48,13 @@ export class TwigsHttpService implements TwigsService { } logout(): Observable { - return this.http.post(this.apiUrl + '/login?logout', this.options); + return Observable.create(emitter => { + this.cookieService.delete('Authorization'); + emitter.next(); + emitter.complete(); + }) + // TODO: Implement this when JWT auth is implemented + // return this.http.post(this.apiUrl + '/login?logout', this.options); } // Budgets