first commit
This commit is contained in:
48
routes/status.go
Normal file
48
routes/status.go
Normal file
@ -0,0 +1,48 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.matterlinux.xyz/matter/security/lib"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
func POSTStatus(c *fiber.Ctx) error {
|
||||
body := struct{
|
||||
ID string `form:"id"`
|
||||
Status string `form:"status"`
|
||||
Message string `form:"message"`
|
||||
}{}
|
||||
|
||||
err := c.BodyParser(&body)
|
||||
if err != nil {
|
||||
return lib.RenderError(c, 400)
|
||||
}
|
||||
|
||||
user, err := lib.GetUser(c)
|
||||
if err != nil {
|
||||
log.Printf("Failed to get the user: %s", err.Error())
|
||||
return lib.RenderError(c, 500)
|
||||
}
|
||||
|
||||
vuln, suc := lib.FindVuln(body.ID)
|
||||
if !suc {
|
||||
return lib.RenderError(c, 404)
|
||||
}
|
||||
|
||||
vuln.Message = body.Message
|
||||
vuln.Status = body.Status
|
||||
if vuln.Author != user.Username && !strings.Contains(vuln.Author, ", "+user.Username){
|
||||
vuln.Author += ", "+user.Username
|
||||
}
|
||||
|
||||
err = lib.UpdateVuln(vuln)
|
||||
if err != nil {
|
||||
log.Printf("Failed to update the vuln: %s", err.Error())
|
||||
return lib.RenderError(c, 500)
|
||||
}
|
||||
|
||||
return c.Redirect("/manage")
|
||||
}
|
Reference in New Issue
Block a user