Search in sources :

Example 1 with BadRequestException

use of com.github.nkonev.aaa.exception.BadRequestException in project videochat by nkonev.

the class UserAccountConverter method buildUserAccountEntityForInsert.

public static UserAccount buildUserAccountEntityForInsert(com.github.nkonev.aaa.dto.EditUserDTO userAccountDTO, PasswordEncoder passwordEncoder) {
    final boolean expired = false;
    final boolean locked = false;
    final boolean enabled = false;
    final UserRole newUserRole = getDefaultUserRole();
    validateLoginAndEmail(userAccountDTO);
    userAccountDTO = validateAndTrimLogin(userAccountDTO);
    String password = userAccountDTO.password();
    try {
        validateUserPassword(password);
    } catch (IllegalArgumentException e) {
        throw new BadRequestException(e.getMessage());
    }
    return new UserAccount(null, CreationType.REGISTRATION, userAccountDTO.login(), passwordEncoder.encode(password), userAccountDTO.avatar(), userAccountDTO.avatarBig(), expired, locked, enabled, newUserRole, userAccountDTO.email(), null, null);
}
Also used : UserRole(com.github.nkonev.aaa.dto.UserRole) BadRequestException(com.github.nkonev.aaa.exception.BadRequestException) UserAccount(com.github.nkonev.aaa.entity.jdbc.UserAccount)

Aggregations

UserRole (com.github.nkonev.aaa.dto.UserRole)1 UserAccount (com.github.nkonev.aaa.entity.jdbc.UserAccount)1 BadRequestException (com.github.nkonev.aaa.exception.BadRequestException)1