added verification blocker

This commit is contained in:
Igor Hrenowitsch Propisnov 2024-07-31 15:32:38 +02:00
parent 37a2d24b36
commit e97743ef17
3 changed files with 62 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import {
HttpStatus, HttpStatus,
Query, Query,
UseGuards, UseGuards,
Post,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger'; import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger';
import { Request } from 'express'; import { Request } from 'express';
@ -22,11 +23,11 @@ export class VerifyController {
) {} ) {}
@ApiCreatedResponse({ @ApiCreatedResponse({
description: 'Email verified successfully', description: 'Verify email',
type: Boolean, type: Boolean,
}) })
@Public() @Public()
@Get() @Post()
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
public async verifyEmail( public async verifyEmail(
@Query('token') tokenToVerify: string @Query('token') tokenToVerify: string

View File

@ -22,3 +22,28 @@
</div> </div>
</div> </div>
</div> </div>
<dialog #emailVerificationModal class="modal">
<div class="modal-box">
<h3 class="text-lg font-bold">Email Verification Required</h3>
<p class="py-4">
To ensure the security and integrity of our platform, we require email
verification before you can create an event. Verifying your email helps
us:
</p>
<ul class="list-disc list-inside mb-4">
<li>Protect your account and event information</li>
<li>Ensure reliable communication with attendees</li>
<li>Maintain the trust and quality of our event community</li>
</ul>
<p class="mb-4">
Would you like to verify your email now to unlock full access to our event
creation tools?
</p>
<div class="modal-action">
<button class="btn btn-primary" (click)="closeEmailVerificationModal()">
I'll Do This Later
</button>
</div>
</div>
</dialog>

View File

@ -1,6 +1,13 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import {
ChangeDetectionStrategy,
Component,
ElementRef,
ViewChild,
} from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { VerifyApiService } from '../../../api';
@Component({ @Component({
selector: 'app-event-empty-state', selector: 'app-event-empty-state',
standalone: true, standalone: true,
@ -9,9 +16,33 @@ import { Router } from '@angular/router';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class EventEmptyStateComponent { export class EventEmptyStateComponent {
public constructor(private readonly router: Router) {} @ViewChild('emailVerificationModal')
public emailVerificationModal!: ElementRef;
public constructor(
private readonly router: Router,
private readonly verifyApi: VerifyApiService
) {}
public navigateToCreateEvent(): void { public navigateToCreateEvent(): void {
this.verifyApi
.verifyControllerIsEmailVerified()
.subscribe((isVerified: boolean) => {
if (!isVerified) {
this.openEmailVerificationModal();
} else {
this.router.navigate(['/event/create']); this.router.navigate(['/event/create']);
} }
});
}
public closeEmailVerificationModal(): void {
(this.emailVerificationModal.nativeElement as HTMLDialogElement).close();
}
private openEmailVerificationModal(): void {
(
this.emailVerificationModal.nativeElement as HTMLDialogElement
).showModal();
}
} }