dev comment logic for check max users
Test Workflow / test (push) Successful in 5s

This commit is contained in:
vladp
2026-02-20 21:53:49 +07:00
parent 5551d84bf7
commit a42e3c72fc
3 changed files with 90 additions and 70 deletions
@@ -17,6 +17,7 @@ import ru.soune.nocopy.entity.user.AuthToken;
import ru.soune.nocopy.entity.user.Permission;
import ru.soune.nocopy.entity.user.User;
import ru.soune.nocopy.entity.user.UserNotActive;
import ru.soune.nocopy.exception.CompanyAlreadyExist;
import ru.soune.nocopy.exception.NotFoundAuthToken;
import ru.soune.nocopy.exception.NotValidFieldException;
import ru.soune.nocopy.repository.*;
@@ -61,7 +62,11 @@ public class AuthService {
AccountType accountType = AccountType.valueOf(registerRequest.getAccountType().toUpperCase());
if (accountType == AccountType.B2B && registerRequest.getCompanyName() != null) {
createCompanyAccount(registerRequest, user);
try {
createCompanyAccount(registerRequest, user);
} catch (CompanyAlreadyExist exist) {
throw new CompanyAlreadyExist("Company already exist");
}
} else if (accountType == AccountType.B2C && registerRequest.getCompanyName() == null) {
createIndividualAccount(user);
} else {
@@ -173,7 +178,7 @@ public class AuthService {
Optional<Company> byInn = companyRepository.findByInn(request.getInn());
if (byInn.isPresent()) {
throw new IllegalStateException("Company was already created");
throw new CompanyAlreadyExist("Company was already created");
}
Company company = new Company();