Add missing handle validation to templates

This commit is contained in:
Tomaž Jerman
2021-08-23 10:14:18 +02:00
parent 19fe1eb46d
commit b2a3a9384b
+8
View File
@@ -196,6 +196,10 @@ func (svc template) Create(ctx context.Context, new *types.Template) (tpl *types
)
err = func() (err error) {
if !handle.IsValid(new.Handle) {
return TemplateErrInvalidHandle()
}
if !svc.ac.CanCreateTemplate(ctx) {
return TemplateErrNotAllowedToCreate()
}
@@ -232,6 +236,10 @@ func (svc template) Update(ctx context.Context, upd *types.Template) (tpl *types
return TemplateErrInvalidID()
}
if !handle.IsValid(upd.Handle) {
return TemplateErrInvalidHandle()
}
if tpl, err = store.LookupTemplateByID(ctx, svc.store, upd.ID); err != nil {
return
}