Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Extract method

Neeraj Gupta47f0c88ed898
diff --git a/server/pkg/controller/user/jwt.go b/server/pkg/controller/user/jwt.go
index d804f4cef3..9cfe61972a 100644
--- a/server/pkg/controller/user/jwt.go
+++ b/server/pkg/controller/user/jwt.go
@@ -17,13 +17,18 @@ func (c *UserController) GetJWTToken(userID int64, scope enteJWT.ClaimScope) (st
if scope == enteJWT.ACCOUNTS {
tokenExpiry = time.NMinFromNow(30)
}
- // Create a new token object, specifying signing method and the claims
- // you would like it to contain.
- token := jwt.NewWithClaims(jwt.SigningMethodHS256, &enteJWT.WebCommonJWTClaim{
+ claim := enteJWT.WebCommonJWTClaim{
UserID: userID,
ExpiryTime: tokenExpiry,
ClaimScope: &scope,
- })
+ }
+ return c.GetJWTTokenForClaim(&claim)
+}
+
+func (c *UserController) GetJWTTokenForClaim(claim *enteJWT.WebCommonJWTClaim) (string, error) {
+ // Create a new token object, specifying signing method and the claims
+ // you would like it to contain.
+ token := jwt.NewWithClaims(jwt.SigningMethodHS256, claim)
// Sign and get the complete encoded token as a string using the secret
tokenString, err := token.SignedString(c.JwtSecret)