mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: use the standard user struct for JWT-Standard to get a correct userinfo (#3809)
This commit is contained in:
parent
9190db1099
commit
b97ae72179
@ -47,6 +47,17 @@ type UserShort struct {
|
|||||||
Phone string `xorm:"varchar(100) index" json:"phone"`
|
Phone string `xorm:"varchar(100) index" json:"phone"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserStandard struct {
|
||||||
|
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
|
||||||
|
Name string `xorm:"varchar(100) notnull pk" json:"preferred_username,omitempty"`
|
||||||
|
|
||||||
|
Id string `xorm:"varchar(100) index" json:"id"`
|
||||||
|
DisplayName string `xorm:"varchar(100)" json:"name,omitempty"`
|
||||||
|
Avatar string `xorm:"varchar(500)" json:"picture,omitempty"`
|
||||||
|
Email string `xorm:"varchar(100) index" json:"email,omitempty"`
|
||||||
|
Phone string `xorm:"varchar(100) index" json:"phone,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type UserWithoutThirdIdp struct {
|
type UserWithoutThirdIdp struct {
|
||||||
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
|
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
|
||||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||||
@ -179,6 +190,20 @@ func getShortUser(user *User) *UserShort {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getStandardUser(user *User) *UserStandard {
|
||||||
|
res := &UserStandard{
|
||||||
|
Owner: user.Owner,
|
||||||
|
Name: user.Name,
|
||||||
|
|
||||||
|
Id: user.Id,
|
||||||
|
DisplayName: user.DisplayName,
|
||||||
|
Avatar: user.Avatar,
|
||||||
|
Email: user.Email,
|
||||||
|
Phone: user.Phone,
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
func getUserWithoutThirdIdp(user *User) *UserWithoutThirdIdp {
|
func getUserWithoutThirdIdp(user *User) *UserWithoutThirdIdp {
|
||||||
res := &UserWithoutThirdIdp{
|
res := &UserWithoutThirdIdp{
|
||||||
Owner: user.Owner,
|
Owner: user.Owner,
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ClaimsStandard struct {
|
type ClaimsStandard struct {
|
||||||
*UserShort
|
*UserStandard
|
||||||
EmailVerified bool `json:"email_verified,omitempty"`
|
EmailVerified bool `json:"email_verified,omitempty"`
|
||||||
PhoneNumber string `json:"phone_number,omitempty"`
|
PhoneNumber string `json:"phone_number,omitempty"`
|
||||||
PhoneNumberVerified bool `json:"phone_number_verified,omitempty"`
|
PhoneNumberVerified bool `json:"phone_number_verified,omitempty"`
|
||||||
@ -48,7 +48,7 @@ func getStreetAddress(user *User) string {
|
|||||||
|
|
||||||
func getStandardClaims(claims Claims) ClaimsStandard {
|
func getStandardClaims(claims Claims) ClaimsStandard {
|
||||||
res := ClaimsStandard{
|
res := ClaimsStandard{
|
||||||
UserShort: getShortUser(claims.User),
|
UserStandard: getStandardUser(claims.User),
|
||||||
EmailVerified: claims.User.EmailVerified,
|
EmailVerified: claims.User.EmailVerified,
|
||||||
TokenType: claims.TokenType,
|
TokenType: claims.TokenType,
|
||||||
Nonce: claims.Nonce,
|
Nonce: claims.Nonce,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user