commit 27c086f63a895a435fb3ea8d931ee8c33ed4bcfd
parent ce7423343ae61556ce94cd7276128be20686add8
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 10 Apr 2018 21:03:58 +0200
Don't check while doing callback as this leads to a wrong state
Diffstat:
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/app/api.service.ts b/src/app/api.service.ts
@@ -45,6 +45,8 @@ export interface Author {
export class ApiService {
url: string;
userUUID: string;
+ inCallback: boolean;
+
constructor(@Inject(DOCUMENT) private document, private http: HttpClient) {
this.url = document.location.protocol + '//' + document.location.hostname + '/api';
}
diff --git a/src/app/callback/twitter/twitter.component.ts b/src/app/callback/twitter/twitter.component.ts
@@ -26,6 +26,7 @@ export class TwitterComponent implements OnInit {
constructor(private apiService: ApiService, private toastr: ToastrService, private route: ActivatedRoute, @Inject(DOCUMENT) private document, private http: HttpClient, private router: Router) {
this.url = document.location.protocol + '//' + document.location.hostname + '/api';
+ this.apiService.inCallback = true;
}
ngOnInit() {
@@ -57,6 +58,7 @@ export class TwitterComponent implements OnInit {
this.apiService.userUUID = data.headers.get('UUID');
// TODO redirect to the Profile instead of home page
+ this.apiService.inCallback = false;
this.router.navigate(['/']);
},
err => {
diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts
@@ -14,6 +14,12 @@ export class NavbarComponent implements OnInit {
constructor(public apiService: ApiService, private toastr: ToastrService) { }
ngOnInit() {
+ if (!this.apiService.inCallback) {
+ this.authCheck();
+ }
+ }
+
+ authCheck() {
this.apiService.checkIfUserIsAuthenticated()
// TODO: Better variable naming
.retryWhen(oerror => {