func PostToken(c *gin.Context) { user := session.User(c) token := token.New(token.UserToken, user.Login) tokenstr, err := token.Sign(user.Hash) if err != nil { c.AbortWithError(http.StatusInternalServerError, err) } else { c.String(http.StatusOK, tokenstr) } }
func DeleteToken(c *gin.Context) { user := session.User(c) user.Hash = base32.StdEncoding.EncodeToString( securecookie.GenerateRandomKey(32), ) if err := store.UpdateUser(c, user); err != nil { c.String(500, "Error revoking tokens. %s", err) return } token := token.New(token.UserToken, user.Login) tokenstr, err := token.Sign(user.Hash) if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } c.String(http.StatusOK, tokenstr) }