mirror of
https://github.com/pushbits/server.git
synced 2025-06-02 10:42:08 +02:00
Check authorization before deleting application
This commit is contained in:
parent
bb5f5c22af
commit
6a77df8373
1 changed files with 8 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
|
@ -80,6 +81,13 @@ func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
user := authentication.GetUser(ctx)
|
||||
|
||||
if user.ID != application.ID {
|
||||
ctx.AbortWithError(http.StatusForbidden, errors.New("only owner can delete application"))
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Deleting application %s.\n", application.Name)
|
||||
|
||||
if success := successOrAbort(ctx, http.StatusInternalServerError, h.Dispatcher.DeregisterApplication(application)); !success {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue