Partially implement updates of models

This commit is contained in:
eikendev 2020-08-02 02:46:38 +02:00
parent 6a77df8373
commit d621333b6e
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
9 changed files with 158 additions and 19 deletions

View file

@ -1,6 +1,11 @@
package api
import (
"errors"
"net/http"
"github.com/eikendev/pushbits/authentication"
"github.com/gin-gonic/gin"
)
@ -11,3 +16,14 @@ func successOrAbort(ctx *gin.Context, code int, err error) bool {
return err == nil
}
func isCurrentUser(ctx *gin.Context, ID uint) bool {
user := authentication.GetUser(ctx)
if user.ID != ID {
ctx.AbortWithError(http.StatusForbidden, errors.New("only owner can delete application"))
return false
}
return true
}