Add missing handle validation to templates

This commit is contained in:
Tomaž Jerman
2021-08-23 10:13:53 +02:00
parent d69b4c3f04
commit 777637d50d
+8
View File
@@ -191,6 +191,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()
}
@@ -227,6 +231,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
}