Get Name from Claims
This commit is contained in:
12
main.go
12
main.go
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user