This commit is contained in:
Jacky 2021-03-29 10:26:16 +08:00
parent 87c2fa520c
commit 855634cd45
10 changed files with 61 additions and 16 deletions

View file

@ -51,12 +51,14 @@ func Login(c *gin.Context) {
func Logout(c *gin.Context) {
token := c.GetHeader("Authorization")
err := model.DeleteToken(token)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": err.Error(),
})
return
if token != "" {
err := model.DeleteToken(token)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": err.Error(),
})
return
}
}
c.JSON(http.StatusNoContent, gin.H{})
}