mirror of
https://github.com/pushbits/server.git
synced 2025-06-07 21:22:04 +02:00
Partially implement updates of models
This commit is contained in:
parent
6a77df8373
commit
d621333b6e
9 changed files with 158 additions and 19 deletions
16
api/util.go
16
api/util.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue