add validation in create member
This commit is contained in:
parent
cc9a92dbab
commit
38dedebae7
|
@ -36,6 +36,21 @@ export class UsersService {
|
||||||
async create(createUserDto: CreateUserDto, currentUser: any) {
|
async create(createUserDto: CreateUserDto, currentUser: any) {
|
||||||
const roles = await this.roleService.findOne(createUserDto.roleId);
|
const roles = await this.roleService.findOne(createUserDto.roleId);
|
||||||
const superior = await this.findByUsername(currentUser.username);
|
const superior = await this.findByUsername(currentUser.username);
|
||||||
|
|
||||||
|
const check = await this.usersRepository.findOne({
|
||||||
|
username: createUserDto.username,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (check) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.NOT_ACCEPTABLE,
|
||||||
|
error: 'Username Already Exist',
|
||||||
|
},
|
||||||
|
HttpStatus.NOT_FOUND,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const salt = randomStringGenerator();
|
const salt = randomStringGenerator();
|
||||||
|
|
||||||
const userData = new User();
|
const userData = new User();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user