Get Name from Claims

This commit is contained in:
2016-11-24 12:08:52 +01:00
parent bd1b3416b4
commit b2ed65788e
2 changed files with 19 additions and 14 deletions

12
main.go
View File

@@ -43,14 +43,18 @@ func main() {
}
func restricted(c *gin.Context) {
//user, _ := c.Get("user") //.(*jwt.Token)
//name := user.Claims["name"].(string)
name := "jan"
claims, ok := verifyLogin(c)
if !ok {
c.Redirect(http.StatusTemporaryRedirect, "/login.html")
return
}
name := claims["name"].(string)
c.String(http.StatusOK, "Welcome "+name+"!")
}
func login(c *gin.Context) {
if verifyLogin(c) {
if _, ok := verifyLogin(c); ok {
c.Redirect(http.StatusTemporaryRedirect, "/api/v1/hello")
return
}