Check ownership of app on GetMessagesWithToken
This commit is contained in:
parent
98df7501f6
commit
4078358aaa
|
|
@ -43,8 +43,12 @@ func (a *MessageAPI) GetMessages(ctx *gin.Context) {
|
||||||
// GetMessagesWithApplication returns all messages from a specific application.
|
// GetMessagesWithApplication returns all messages from a specific application.
|
||||||
func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context) {
|
func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context) {
|
||||||
withID(ctx, "appid", func(id uint) {
|
withID(ctx, "appid", func(id uint) {
|
||||||
messages := a.DB.GetMessagesByApplication(id)
|
if app := a.DB.GetApplicationByID(id); app != nil && app.UserID == auth.GetUserID(ctx) {
|
||||||
ctx.JSON(200, messages)
|
messages := a.DB.GetMessagesByApplication(id)
|
||||||
|
ctx.JSON(200, messages)
|
||||||
|
} else {
|
||||||
|
ctx.AbortWithError(404, errors.New("application does not exist"))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue