Make name required for auth clients
This commit is contained in:
@@ -187,6 +187,10 @@ func (svc *authClient) Create(ctx context.Context, new *types.AuthClient) (res *
|
||||
)
|
||||
|
||||
err = func() (err error) {
|
||||
if new.Meta.Name == "" {
|
||||
return AuthClientErrMissingName()
|
||||
}
|
||||
|
||||
if !svc.ac.CanCreateAuthClient(ctx) {
|
||||
return AuthClientErrNotAllowedToCreate()
|
||||
}
|
||||
@@ -260,6 +264,9 @@ func (svc *authClient) Update(ctx context.Context, upd *types.AuthClient) (res *
|
||||
if upd.ID == 0 {
|
||||
return AuthClientErrInvalidID()
|
||||
}
|
||||
if upd.Meta.Name == "" {
|
||||
return AuthClientErrMissingName()
|
||||
}
|
||||
|
||||
if res, err = loadAuthClient(ctx, svc.store, upd.ID); err != nil {
|
||||
return
|
||||
|
||||
34
server/system/service/auth_client_actions.gen.go
generated
34
server/system/service/auth_client_actions.gen.go
generated
@@ -503,6 +503,40 @@ func AuthClientErrInvalidID(mm ...*authClientActionProps) *errors.Error {
|
||||
return e
|
||||
}
|
||||
|
||||
// AuthClientErrMissingName returns "system:auth-client.missingName" as *errors.Error
|
||||
//
|
||||
//
|
||||
// This function is auto-generated.
|
||||
//
|
||||
func AuthClientErrMissingName(mm ...*authClientActionProps) *errors.Error {
|
||||
var p = &authClientActionProps{}
|
||||
if len(mm) > 0 {
|
||||
p = mm[0]
|
||||
}
|
||||
|
||||
var e = errors.New(
|
||||
errors.KindInternal,
|
||||
|
||||
p.Format("missing name", nil),
|
||||
|
||||
errors.Meta("type", "missingName"),
|
||||
errors.Meta("resource", "system:auth-client"),
|
||||
|
||||
errors.Meta(authClientPropsMetaKey{}, p),
|
||||
|
||||
// translation namespace & key
|
||||
errors.Meta(locale.ErrorMetaNamespace{}, "system"),
|
||||
errors.Meta(locale.ErrorMetaKey{}, "auth-client.errors.missingName"),
|
||||
|
||||
errors.StackSkip(1),
|
||||
)
|
||||
|
||||
if len(mm) > 0 {
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
// AuthClientErrUnknownGrantType returns "system:auth-client.unknownGrantType" as *errors.Error
|
||||
//
|
||||
//
|
||||
|
||||
@@ -61,6 +61,9 @@ errors:
|
||||
message: "invalid ID"
|
||||
severity: warning
|
||||
|
||||
- error: missingName
|
||||
message: "missing name"
|
||||
|
||||
- error: unknownGrantType
|
||||
message: "unknown grant type"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user