Created
December 14, 2019 01:09
-
-
Save manakuro/d8c447c41dc6f076dbed9bce57d7cd02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Token struct { | |
Token string `json:"token"` | |
} | |
func SignIn() echo.HandlerFunc { | |
return func(c echo.Context) error { | |
username := c.FormValue("username") | |
password := c.FormValue("password") | |
if username == "you" && password == "passed" { | |
token, err := auth.GenerateToken() | |
if err != nil { | |
return err | |
} | |
return c.JSON(http.StatusOK, Token{ | |
Token: token, | |
}) | |
} | |
return echo.ErrUnauthorized | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment