Merge pull request #329 from authorizerdev/fix/add-sub-user-info
[server][fix]: add sub to userinfo
This commit is contained in:
commit
7dd20128af
|
@ -1,6 +1,8 @@
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -39,7 +41,28 @@ func UserInfoHandler() gin.HandlerFunc {
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
apiUser := user.AsAPIUser()
|
||||||
gc.JSON(http.StatusOK, user.AsAPIUser())
|
userBytes, err := json.Marshal(apiUser)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("Error marshalling user: ", err)
|
||||||
|
gc.JSON(http.StatusUnauthorized, gin.H{
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("=> str:", string(userBytes))
|
||||||
|
res := map[string]interface{}{}
|
||||||
|
err = json.Unmarshal(userBytes, &res)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("Error un-marshalling user: ", err)
|
||||||
|
gc.JSON(http.StatusUnauthorized, gin.H{
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// add sub field to user as per openid standards
|
||||||
|
// https://github.com/authorizerdev/authorizer/issues/327
|
||||||
|
res["sub"] = userID
|
||||||
|
gc.JSON(http.StatusOK, res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user