diff --git a/src/app/user-verification/user-verification.component.html b/src/app/user-verification/user-verification.component.html index aa9e1b2538ab361515b54ef492a6352906704cb9..f514687e3ee16e2b4bc68c22e3b407a7a088d385 100644 --- a/src/app/user-verification/user-verification.component.html +++ b/src/app/user-verification/user-verification.component.html @@ -2,13 +2,17 @@ <p *ngIf="!verificationSuccess && !verificationIssue">Votre email est en cours de vérification ...</p> <div *ngIf="verificationSuccess"> <div class="title"> - <h3> + <h3 *ngIf="structure"> Bravo !<br /> Votre compte et votre structure ont bien été référencés. </h3> + <h3 *ngIf="!structure"> + Bravo !<br /> + Votre compte a bien été créé. + </h3> </div> - <div class="structureInfoBlock" fxLayout="row" fxLayoutAlign=" center"> + <div *ngIf="structure" class="structureInfoBlock" fxLayout="row" fxLayoutAlign=" center"> <div class="structureInfoContent" fxLayout="column"> {{ structure.structureName }} <span>{{ structure.structureType }}</span> @@ -20,7 +24,7 @@ </div> </div> <div class="btnSection"> - <button class="btn" routerLink="/home" [state]="{ data: structure }">Voir ma structure</button> + <button *ngIf="structure" class="btn" routerLink="/home" [state]="{ data: structure }">Voir ma structure</button> </div> </div> <p *ngIf="verificationIssue"> diff --git a/src/app/user-verification/user-verification.component.ts b/src/app/user-verification/user-verification.component.ts index 2e97d1938ae1f34948d865d38af9374433a59d1e..9af616e60dc72322537de2e0c64a4652b54377e1 100644 --- a/src/app/user-verification/user-verification.component.ts +++ b/src/app/user-verification/user-verification.component.ts @@ -35,23 +35,27 @@ export class UserVerificationComponent implements OnInit { private sendVerification(): void { this.authService.verifyUser(this.userId, this.token).subscribe( (user: User) => { - this.structureService.getStructure(user.structuresLink[0]).subscribe( - (structure) => { - structure.accountVerified = true; - this.structure = structure; - this.structureService.updateStructureAfterOwnerVerify(structure._id, user).subscribe( - () => { - this.verificationSuccess = true; - }, - () => { - this.verificationIssue = true; - } - ); - }, - () => { - this.verificationIssue = true; - } - ); + if (user.structuresLink[0]) { + this.structureService.getStructure(user.structuresLink[0]).subscribe( + (structure) => { + structure.accountVerified = true; + this.structure = structure; + this.structureService.updateStructureAfterOwnerVerify(structure._id, user).subscribe( + () => { + this.verificationSuccess = true; + }, + () => { + this.verificationIssue = true; + } + ); + }, + () => { + this.verificationIssue = true; + } + ); + } else { + this.verificationSuccess = true; + } }, () => { this.verificationIssue = true;