@ibiz-template/runtime 0.4.9 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -6217,7 +6217,7 @@ var AuthorityService = class {
6217
6217
 
6218
6218
  // src/service/service/auth/v7-auth.service.ts
6219
6219
  import { CoreConst } from "@ibiz-template/core";
6220
- import { clearCookie, setCookie } from "qx-util";
6220
+ import { clearCookie, getCookie, setCookie } from "qx-util";
6221
6221
  var V7AuthService = class {
6222
6222
  async login(loginname, password, rememberme) {
6223
6223
  try {
@@ -6228,9 +6228,14 @@ var V7AuthService = class {
6228
6228
  });
6229
6229
  const { data } = res;
6230
6230
  if (data && data.token) {
6231
- setCookie(CoreConst.TOKEN, data.token, 0, true);
6231
+ setCookie(CoreConst.TOKEN, data.token, rememberme ? 7 : 0, true);
6232
6232
  const expiredDate = (/* @__PURE__ */ new Date()).getTime() + (data.expirein || 7199) * 1e3;
6233
- setCookie(CoreConst.TOKEN_EXPIRES, "".concat(expiredDate), 0, true);
6233
+ setCookie(
6234
+ CoreConst.TOKEN_EXPIRES,
6235
+ "".concat(expiredDate),
6236
+ rememberme ? 7 : 0,
6237
+ true
6238
+ );
6234
6239
  }
6235
6240
  return true;
6236
6241
  } catch (err) {
@@ -6255,6 +6260,24 @@ var V7AuthService = class {
6255
6260
  }
6256
6261
  return false;
6257
6262
  }
6263
+ async extendLogin() {
6264
+ const token = getCookie(CoreConst.TOKEN);
6265
+ const expirein = getCookie(CoreConst.TOKEN_EXPIRES);
6266
+ if (token && expirein) {
6267
+ let wait = Number(expirein) - (/* @__PURE__ */ new Date()).getTime();
6268
+ const early = 5 * 60 * 1e3;
6269
+ wait = wait > early ? wait - early : 0;
6270
+ setTimeout(async () => {
6271
+ const res = await ibiz.net.get("/uaa/refreshtoken2");
6272
+ if (res.ok) {
6273
+ setCookie(CoreConst.TOKEN, res.data.token, 0, true);
6274
+ const expiredDate = (/* @__PURE__ */ new Date()).getTime() + (res.data.expirein || 7199) * 1e3;
6275
+ setCookie(CoreConst.TOKEN_EXPIRES, "".concat(expiredDate), 0, true);
6276
+ }
6277
+ this.extendLogin();
6278
+ }, wait);
6279
+ }
6280
+ }
6258
6281
  };
6259
6282
 
6260
6283
  // src/service/service/async-action/async-action.service.ts