File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
packages/server/src/templates Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -85,18 +85,23 @@ export function generateJwt(options: GenerateJWTOptions = {}): string {
8585 alg : "HS256" ,
8686 typ : "JWT" ,
8787 } ) ;
88- payload . iss || ( payload . iss = "dokploy" ) ;
89- payload . iat || ( payload . iat = Math . floor ( Date . now ( ) / 1000 ) ) ;
90- payload . exp ||
91- ( payload . exp = Math . floor (
92- new Date ( "2030-01-01T00:00:00Z" ) . getTime ( ) / 1000 ,
93- ) ) ;
88+ if ( ! payload . iss ) {
89+ payload . iss = "dokploy" ;
90+ }
91+ if ( ! payload . iat ) {
92+ payload . iat = Math . floor ( Date . now ( ) / 1000 ) ;
93+ }
94+ if ( ! payload . exp ) {
95+ payload . exp = Math . floor ( new Date ( "2030-01-01T00:00:00Z" ) . getTime ( ) / 1000 ) ;
96+ }
9497 const encodedPayload = objToJWTBase64 ( {
9598 iat : Math . floor ( Date . now ( ) / 1000 ) ,
9699 exp : Math . floor ( new Date ( "2030-01-01T00:00:00Z" ) . getTime ( ) / 1000 ) ,
97100 ...payload ,
98101 } ) ;
99- secret || ( secret = randomBytes ( 32 ) . toString ( "hex" ) ) ;
102+ if ( ! secret ) {
103+ secret = randomBytes ( 32 ) . toString ( "hex" ) ;
104+ }
100105 const signature = safeBase64 (
101106 createHmac ( "SHA256" , secret )
102107 . update ( `${ encodedHeader } .${ encodedPayload } ` )
You can’t perform that action at this time.
0 commit comments