Implement share DELETE
This commit is contained in:
parent
1232b6887a
commit
cf498d241a
2 changed files with 26 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue