mirror of
https://github.com/pushbits/server.git
synced 2025-06-06 04:32:11 +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
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
@ -80,6 +81,13 @@ func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context) {
|
||||||
return
|
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)
|
log.Printf("Deleting application %s.\n", application.Name)
|
||||||
|
|
||||||
if success := successOrAbort(ctx, http.StatusInternalServerError, h.Dispatcher.DeregisterApplication(application)); !success {
|
if success := successOrAbort(ctx, http.StatusInternalServerError, h.Dispatcher.DeregisterApplication(application)); !success {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue