package jwt import ( "net/http" "github.com/gin-gonic/gin" "github.com/ycyxuehan/zelda/apiserver/auth/api" ) //登录 func (m *manager) HandlerLogin(identifyFunc api.IdentifyFunc) gin.HandlerFunc { return func(c *gin.Context) { authRequest := api.AuthentitionRequest{} err := c.Bind(&authRequest) if err != nil { c.JSON(http.StatusOK, &api.AuthentitionResponse{Error: err}) return } resp := m.Login(identifyFunc, &authRequest) c.JSON(http.StatusOK, resp) } } //登出 func (m *manager) HandlerLogout() gin.HandlerFunc { return func(c *gin.Context) { authRequest := api.AuthentitionRequest{} err := c.Bind(&authRequest) if err != nil { c.JSON(http.StatusOK, &api.AuthentitionResponse{Error: err}) return } resp := m.Logout(&authRequest) c.JSON(http.StatusOK, resp) } } //刷新token func (m *manager) HandlerRefreshToken() gin.HandlerFunc { return func(c *gin.Context) { authRequest := api.AuthentitionRequest{} err := c.Bind(&authRequest) if err != nil { c.JSON(http.StatusOK, &api.AuthentitionResponse{Error: err}) return } resp := m.Refresh(&authRequest) c.JSON(http.StatusOK, resp) } }