Shares #109

Merged
amigan merged 59 commits from shareUI into trunk 2025-02-14 00:25:03 -05:00
2 changed files with 26 additions and 1 deletions
Showing only changes of commit cf498d241a - Show all commits

View file

@ -213,4 +213,24 @@ func (sa *shareAPI) routeShare(w http.ResponseWriter, r *http.Request) {
}
func (sa *shareAPI) deleteShare(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
shs := shares.FromCtx(ctx)
p := struct {
ID string `param:"id"`
}{}
err := decodeParams(&p, r)
if err != nil {
wErr(w, r, autoError(err))
return
}
err = shs.Delete(ctx, p.ID)
if err != nil {
wErr(w, r, autoError(err))
return
}
w.WriteHeader(http.StatusNoContent)
}

View file

@ -80,7 +80,12 @@ func (s *postgresStore) Create(ctx context.Context, share *Share) error {
}
func (s *postgresStore) Delete(ctx context.Context, id string) error {
_, err := rbac.Check(ctx, new(Share), rbac.WithActions(entities.ActionDelete))
sh, err := s.GetShare(ctx, id)
if err != nil {
return err
}
_, err = rbac.Check(ctx, sh, rbac.WithActions(entities.ActionDelete))
if err != nil {
return err
}