fix: allow single parameter in org unique request (#3620)

This commit is contained in:
Livio Amstutz 2022-05-13 11:25:45 +02:00 committed by GitHub
parent a9f82529ab
commit f70990709b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -2403,12 +2403,13 @@ This is an empty response
### IsOrgUniqueRequest ### IsOrgUniqueRequest
if name or domain is already in use, org is not unique if name or domain is already in use, org is not unique
at least one argument has to be provided
| Field | Type | Description | Validation | | Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- | | ----- | ---- | ----------- | ----------- |
| name | string | - | string.min_len: 1<br /> string.max_len: 200<br /> | | name | string | - | string.max_len: 200<br /> |
| domain | string | - | string.min_len: 1<br /> string.max_len: 200<br /> | | domain | string | - | string.max_len: 200<br /> |

View File

@ -115,6 +115,9 @@ func (q *Queries) OrgByDomainGlobal(ctx context.Context, domain string) (*Org, e
} }
func (q *Queries) IsOrgUnique(ctx context.Context, name, domain string) (isUnique bool, err error) { func (q *Queries) IsOrgUnique(ctx context.Context, name, domain string) (isUnique bool, err error) {
if name == "" && domain == "" {
return false, errors.ThrowInvalidArgument(nil, "QUERY-DGqfd", "Errors.Query.InvalidRequest")
}
query, scan := prepareOrgUniqueQuery() query, scan := prepareOrgUniqueQuery()
stmt, args, err := query.Where( stmt, args, err := query.Where(
sq.And{ sq.And{

View File

@ -2725,6 +2725,7 @@ message UpdateOIDCSettingsResponse {
} }
// if name or domain is already in use, org is not unique // if name or domain is already in use, org is not unique
// at least one argument has to be provided
message IsOrgUniqueRequest { message IsOrgUniqueRequest {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema: { json_schema: {
@ -2734,18 +2735,16 @@ message IsOrgUniqueRequest {
}; };
string name = 1 [ string name = 1 [
(validate.rules).string = {min_len: 1, max_len: 200}, (validate.rules).string = {max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"CAOS AG\""; example: "\"CAOS AG\"";
min_length: 1;
max_length: 200; max_length: 200;
} }
]; ];
string domain = 2 [ string domain = 2 [
(validate.rules).string = {min_len: 1, max_len: 200}, (validate.rules).string = {max_len: 200},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"caos.ch\""; example: "\"caos.ch\"";
min_length: 1;
max_length: 200; max_length: 200;
} }
]; ];