MCPcopy Create free account
hub / github.com/TalkingData/owl / Logout

Function Logout

api/users.go:313–333  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

311}
312
313func Logout(c *gin.Context) {
314 tokenString, err := c.Cookie("token")
315 if err != nil || len(tokenString) == 0 {
316 c.JSON(http.StatusOK, gin.H{"code": http.StatusUnauthorized})
317 return
318 }
319 token, err := ValidateToken(tokenString)
320 if err != nil {
321 c.JSON(http.StatusOK, gin.H{"code": http.StatusBadRequest, "message": "token is valied"})
322 return
323 }
324 if config.AuthType == "iam" {
325 if err = iamLogout(token); err != nil {
326 log.Println("iam logout failed", err)
327 c.JSON(http.StatusOK, gin.H{"code": http.StatusInternalServerError, "message": "iam logout failed"})
328 return
329 }
330 }
331 c.SetCookie("token", "", -1, "/", "", false, true)
332 c.JSON(http.StatusOK, gin.H{"code": http.StatusUnauthorized, "link": "/", "message": "logout sucessfully"})
333}
334
335func iamLogout(token *jwt.Token) error {
336 claims := token.Claims.(jwt.MapClaims)

Callers

nothing calls this directly

Calls 2

ValidateTokenFunction · 0.85
iamLogoutFunction · 0.85

Tested by

no test coverage detected