added user logout

main
alex 2023-04-20 19:17:19 +02:00
parent 12cff8e623
commit 8f76aa49bd
1 changed files with 14 additions and 0 deletions

View File

@ -67,6 +67,20 @@ func UserLogin(c *fiber.Ctx) error {
return c.JSON(structs.UserLoginResponse{Session: session}) return c.JSON(structs.UserLoginResponse{Session: session})
} }
func UserLogout(c *fiber.Ctx) error {
session := utils.GetXAuhorizationHeader(c)
if len(session) != utils.LenHeaderXAuthorization {
return c.SendStatus(fiber.StatusUnauthorized)
}
log.Info().Msg(session)
database.DB.Delete(&structs.UserSession{}, "id = ?", session)
return c.SendStatus(fiber.StatusCreated)
}
func validatePasswordLength(password string) bool { func validatePasswordLength(password string) bool {
lenPassword := len(password) lenPassword := len(password)