bugfix
This commit is contained in:
@@ -52,6 +52,7 @@ func (store *Store) CheckToken(ctx *gin.Context) {
|
|||||||
tx := store.DB.First(&user)
|
tx := store.DB.First(&user)
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
ctx.JSON(http.StatusNotFound, tx.Error.Error())
|
ctx.JSON(http.StatusNotFound, tx.Error.Error())
|
||||||
|
removeCookies(ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ func (store *Store) RefreshToken(ctx *gin.Context) {
|
|||||||
tx := store.DB.First(&user, userID)
|
tx := store.DB.First(&user, userID)
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
ctx.JSON(http.StatusNotFound, tx.Error.Error())
|
ctx.JSON(http.StatusNotFound, tx.Error.Error())
|
||||||
|
removeCookies(ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,22 +159,26 @@ func (store *Store) Login(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) Logout(ctx *gin.Context) {
|
func (store *Store) Logout(ctx *gin.Context) {
|
||||||
|
removeCookies(ctx)
|
||||||
|
|
||||||
|
ctx.Status(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeCookies(ctx *gin.Context) {
|
||||||
ctx.SetCookie(
|
ctx.SetCookie(
|
||||||
"access_token",
|
"access_token",
|
||||||
"",
|
"",
|
||||||
-1,
|
-1,
|
||||||
store.Auth.Config.Endpoint,
|
"",
|
||||||
store.Auth.Config.Domain,
|
"",
|
||||||
true, true,
|
true, true,
|
||||||
)
|
)
|
||||||
ctx.SetCookie(
|
ctx.SetCookie(
|
||||||
"refresh_token",
|
"refresh_token",
|
||||||
"",
|
"",
|
||||||
-1,
|
-1,
|
||||||
store.Auth.Config.Endpoint,
|
"",
|
||||||
store.Auth.Config.Domain,
|
"",
|
||||||
true, true,
|
true, true,
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.Status(http.StatusOK)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user