@@ -99,13 +99,22 @@ class AdminForthAuth implements IAdminForthAuth {
9999 }
100100
101101 setCustomCookie ( { response, payload } : {
102- response : any , payload : { name : string , value : string , expiry : number , httpOnly : boolean }
102+ response : any , payload : { name : string , value : string , expiry : number | undefined , expirySeconds : number | undefined , httpOnly : boolean }
103103 } ) {
104- const { name, value, expiry, httpOnly} = payload ;
104+ const { name, value, expiry, httpOnly, expirySeconds } = payload ;
105+
106+ let expiryMs = 24 * 60 * 60 * 1000 ; // default 1 day
107+ if ( expirySeconds !== undefined ) {
108+ expiryMs = expirySeconds * 1000 ;
109+ } else if ( expiry !== undefined ) {
110+ console . warn ( 'setCustomCookie: expiry(in ms) is deprecated, use expirySeconds instead (seconds), traceback:' , new Error ( ) . stack ) ;
111+ expiryMs = expiry ;
112+ }
113+
105114 const brandSlug = this . adminforth . config . customization . brandNameSlug ;
106115 response . setHeader ( 'Set-Cookie' , `adminforth_${ brandSlug } _${ name } =${ value } ; Path=${ this . adminforth . config . baseUrl || '/' } ;${
107116 httpOnly ? ' HttpOnly;' : ''
108- } SameSite=Strict; Expires=${ new Date ( Date . now ( ) + expiry ) . toUTCString ( ) } `) ;
117+ } SameSite=Strict; Expires=${ new Date ( Date . now ( ) + expiryMs ) . toUTCString ( ) } `) ;
109118 }
110119
111120 getCustomCookie ( { cookies, name } : {
0 commit comments