mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-18 12:33:21 +00:00
add email account validation
This commit is contained in:
@@ -8,11 +8,11 @@ import {
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { UsersService } from '../services/users.service';
|
||||
import { CreateUserDto } from '../dto/create-user.dto';
|
||||
import { Pagination } from '../../../infrastructure/common/pagination.service';
|
||||
import { BaseAuthGuard } from '../../auth/guards/base-auth.guard';
|
||||
} from '@nestjs/common'
|
||||
import { UsersService } from '../services/users.service'
|
||||
import { CreateUserDto } from '../dto/create-user.dto'
|
||||
import { Pagination } from '../../../infrastructure/common/pagination.service'
|
||||
import { BaseAuthGuard } from '../../auth/guards/base-auth.guard'
|
||||
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
@@ -20,28 +20,31 @@ export class UsersController {
|
||||
|
||||
@Get()
|
||||
async findAll(@Query() query) {
|
||||
const { page, pageSize, searchNameTerm } =
|
||||
Pagination.getPaginationData(query);
|
||||
const users = await this.usersService.getUsers(
|
||||
page,
|
||||
pageSize,
|
||||
searchNameTerm,
|
||||
);
|
||||
if (!users) throw new NotFoundException('Users not found');
|
||||
return users;
|
||||
const { page, pageSize, searchNameTerm, searchEmailTerm } = Pagination.getPaginationData(query)
|
||||
const users = await this.usersService.getUsers(page, pageSize, searchNameTerm, searchEmailTerm)
|
||||
if (!users) throw new NotFoundException('Users not found')
|
||||
return users
|
||||
}
|
||||
|
||||
//@UseGuards(BaseAuthGuard)
|
||||
@Post()
|
||||
async create(@Body() createUserDto: CreateUserDto) {
|
||||
return await this.usersService.createUser(
|
||||
createUserDto.login,
|
||||
createUserDto.password,
|
||||
createUserDto.email,
|
||||
);
|
||||
createUserDto.email
|
||||
)
|
||||
}
|
||||
|
||||
@UseGuards(BaseAuthGuard)
|
||||
@Delete(':id')
|
||||
async remove(@Param('id') id: string) {
|
||||
return await this.usersService.deleteUserById(id);
|
||||
return await this.usersService.deleteUserById(id)
|
||||
}
|
||||
|
||||
@UseGuards(BaseAuthGuard)
|
||||
@Delete()
|
||||
async removeAll() {
|
||||
return await this.usersService.deleteAllUsers()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user