diff --git a/src/app/auth/login.component.ts b/src/app/auth/login.component.ts index 829de5d..8a28be0 100644 --- a/src/app/auth/login.component.ts +++ b/src/app/auth/login.component.ts @@ -34,6 +34,7 @@ export class LoginComponent implements OnInit { .subscribe( result => { console.log('Logged out!'); + localStorage.clear(); } ); diff --git a/src/app/dashboard/feedback.component.html b/src/app/dashboard/feedback.component.html index d827b99..dd844e6 100644 --- a/src/app/dashboard/feedback.component.html +++ b/src/app/dashboard/feedback.component.html @@ -11,8 +11,8 @@
- - Your email will load here. + + Enter your email here if it doesn't show.
diff --git a/src/app/dashboard/feedback.component.ts b/src/app/dashboard/feedback.component.ts index 9350c3d..e5d6502 100644 --- a/src/app/dashboard/feedback.component.ts +++ b/src/app/dashboard/feedback.component.ts @@ -10,7 +10,7 @@ import 'rxjs/add/operator/map'; }) export class FeedbackComponent { feedbackForm: FormGroup; - loggedInEmail: any; + loggedInEmail: string; noEmail: boolean = false; username: any; feedbackFormStatus: any; @@ -21,17 +21,36 @@ export class FeedbackComponent { private formBuilder: FormBuilder, private api: ApiService, ) { - this.loggedInEmail = localStorage.getItem('email'); - if (this.loggedInEmail == null) { - this.noEmail = true; - } - this.feedbackForm = this.formBuilder.group({ email: ['', [Validators.required]], feedbacktext: ['', [Validators.required]], }); } + ngOnInit(): void { + + if(localStorage.getItem('email')) { + this.loggedInEmail = localStorage.getItem('email'); + } + console.log('loggedInEmail: ' + this.loggedInEmail); + if (this.loggedInEmail) { + console.log('email not found in storage'); + this.api.accountFullLoad().subscribe( + result => { + console.log(result); + this.feedbackForm.patchValue({ + email: result.email, + }); + this.api.setUserInfo( result.email, result.display_name ); + }, + error => { + console.log( error._body ); + this.noEmail = true; + } + ); + } + } + onSubmit() { this.api .feedback(this.feedbackForm.value) diff --git a/src/app/layouts/full-layout.component.ts b/src/app/layouts/full-layout.component.ts index dd7ca12..375151a 100644 --- a/src/app/layouts/full-layout.component.ts +++ b/src/app/layouts/full-layout.component.ts @@ -40,6 +40,7 @@ export class FullLayoutComponent implements OnInit { .subscribe( result => { console.log('Logged out!'); + localStorage.clear(); this.router.navigate(['/login']); } ); diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 93edc5e..17da0c8 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -66,7 +66,7 @@ export class ApiService { result.email, result.display_name ); - this.setUserType(result.user_type) + this.setUserType(result.user_type) } ); return login_event;