Merge branch 'development' into 'devops-staging'

add validation in create member

See merge request empatnusabangsa/ppob/ppob-backend!15
This commit is contained in:
ilham dwi pratama 2021-12-10 08:32:01 +00:00
commit c85199c337

View File

@ -36,6 +36,21 @@ export class UsersService {
async create(createUserDto: CreateUserDto, currentUser: any) {
const roles = await this.roleService.findOne(createUserDto.roleId);
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 userData = new User();