feat: tweak userinfo

This commit is contained in:
Nya Candy 2023-01-25 11:01:50 +08:00
parent 7188db21b6
commit 759cc3ead5
No known key found for this signature in database
GPG Key ID: 8B1BE5E86F2E66AE
1 changed files with 8 additions and 3 deletions

View File

@ -12,6 +12,11 @@ import (
"strings"
)
type UserinfoResponse struct {
types.MisskeyUser
EMail string `json:"email"`
}
func UserInfo(ctx *gin.Context) {
// Get token from header
accessToken := strings.Replace(ctx.GetHeader("Authorization"), "Bearer ", "", 1)
@ -65,9 +70,9 @@ func UserInfo(ctx *gin.Context) {
return
}
ctx.JSON(http.StatusOK, gin.H{
"email": tokenInfo.Sub,
"user": acceptCtx.User,
ctx.JSON(http.StatusOK, UserinfoResponse{
MisskeyUser: acceptCtx.User,
EMail: *tokenInfo.Sub,
})
}