Skip to content

Commit

Permalink
add support phone and kyc for jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhagunn committed Mar 15, 2023
1 parent 283ab15 commit 1585c32
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type Auth struct {
Username string `json:"username"`
Role string `json:"role"`
ReferralUID null.String `json:"referral_uid,omitempty"`
HasPhone bool `json:"has_phone"`
Phone string `json:"phone"`
KYC bool `json:"kyc"`
OTP bool `json:"otp"`
Level int `json:"level"`
Audience []string `json:"aud,omitempty"`
Expand Down Expand Up @@ -54,7 +55,7 @@ func appendClaims(defaultClaims, customClaims jwt.MapClaims) jwt.MapClaims {
}

// ForgeToken creates a valid JWT signed by the given private key
func ForgeToken(uid, email, role string, referralUID null.String, level int64, otp bool, hasPhone bool, data map[string]interface{}, key *rsa.PrivateKey, customClaims jwt.MapClaims) (string, error) {
func ForgeToken(uid, email, role string, referralUID null.String, level int64, otp bool, phone string, kyc bool, data map[string]interface{}, key *rsa.PrivateKey, customClaims jwt.MapClaims) (string, error) {
claims := appendClaims(jwt.MapClaims{
"iat": time.Now().Unix(),
"jti": strconv.FormatInt(time.Now().Unix(), 10),
Expand All @@ -68,7 +69,8 @@ func ForgeToken(uid, email, role string, referralUID null.String, level int64, o
"level": level,
"state": "active",
"referral_uid": referralUID,
"has_phone": hasPhone,
"phone": phone,
"kyc": kyc,
"otp": otp,
"data": data,
}, customClaims)
Expand Down

0 comments on commit 1585c32

Please sign in to comment.