This commit is contained in:
2024-05-02 16:58:01 +01:00
parent 29b69deaf6
commit 7d346ba2ce
3 changed files with 18 additions and 1 deletions

View File

@@ -412,6 +412,18 @@ func UsersEndpints(db db.Db, handle *Handle) {
return c.SendJSON("Ok")
})
handle.DeleteAuth("/user/token/logoff", User_Normal, func(c *Context) *Error {
if c.Token == nil {
return c.JsonBadRequest("Failed to get token")
}
_, err := c.Db.Exec("delete from tokens where token=$1;", c.Token)
if err != nil {
return c.E500M("Failed to delete token", err)
}
return c.SendJSON("OK")
})
type DeleteUser struct {
Id string `json:"id" validate:"required"`
Password string `json:"password" validate:"required"`