strapi-custom-auth 1.2.29 → 1.2.31

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.
@@ -2980,7 +2980,7 @@ async function cognitoSignIn(ctx) {
2980
2980
  async function cognitoSignInCallback(ctx) {
2981
2981
  const config2 = configValidation$2();
2982
2982
  const userService = strapi.service("admin::user");
2983
- const tokenService = strapi.service("admin::token");
2983
+ strapi.service("admin::token");
2984
2984
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
2985
2985
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
2986
2986
  if (!ctx.query.code) {
@@ -3019,7 +3019,9 @@ async function cognitoSignInCallback(ctx) {
3019
3019
  let jwtToken;
3020
3020
  if (dbUser) {
3021
3021
  activateUser = dbUser;
3022
- jwtToken = await tokenService.createToken(dbUser);
3022
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3023
+ id: activateUser.id
3024
+ });
3023
3025
  } else {
3024
3026
  const cognitoRoles = await roleService.cognitoRoles();
3025
3027
  const roles2 = cognitoRoles && cognitoRoles["roles"] ? cognitoRoles["roles"].map((role2) => ({
@@ -3033,7 +3035,9 @@ async function cognitoSignInCallback(ctx) {
3033
3035
  defaultLocale,
3034
3036
  roles2
3035
3037
  );
3036
- jwtToken = await tokenService.createToken(activateUser);
3038
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3039
+ id: activateUser.id
3040
+ });
3037
3041
  await oauthService.triggerWebHook(activateUser);
3038
3042
  }
3039
3043
  oauthService.triggerSignInSuccess(activateUser);
@@ -3096,7 +3100,7 @@ async function customSignIn(ctx) {
3096
3100
  }
3097
3101
  async function customSignInCallback(ctx) {
3098
3102
  const userService = strapi.service("admin::user");
3099
- const tokenService = strapi.service("admin::token");
3103
+ strapi.service("admin::token");
3100
3104
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3101
3105
  const nonce = v4$1();
3102
3106
  try {
@@ -3108,7 +3112,9 @@ async function customSignInCallback(ctx) {
3108
3112
  }
3109
3113
  if (dbUser) {
3110
3114
  activateUser = dbUser;
3111
- jwtToken = await tokenService.createToken(dbUser);
3115
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3116
+ id: activateUser.id
3117
+ });
3112
3118
  }
3113
3119
  oauthService.triggerSignInSuccess(activateUser);
3114
3120
  const html = oauthService.renderSignUpSuccess(jwtToken, activateUser, nonce);
@@ -3177,7 +3183,7 @@ async function customSignInMfa(ctx) {
3177
3183
  }
3178
3184
  }
3179
3185
  async function customConfirmMfa(ctx) {
3180
- const tokenService = strapi.service("admin::token");
3186
+ strapi.service("admin::token");
3181
3187
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3182
3188
  const nonce = v4$1();
3183
3189
  const { code, id, uid } = ctx.query;
@@ -3199,7 +3205,9 @@ async function customConfirmMfa(ctx) {
3199
3205
  if (!otp2) {
3200
3206
  throw new Error("Invalid code");
3201
3207
  }
3202
- jwtToken = await tokenService.createToken(otp2.user);
3208
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3209
+ id: otp2.user.id
3210
+ });
3203
3211
  await strapi.query("plugin::strapi-custom-auth.mfaotp").delete({
3204
3212
  where: {
3205
3213
  id
@@ -3282,7 +3290,7 @@ async function microsoftSignInCallback(ctx) {
3282
3290
  console.log("[STRAPI-CUSTOM-AUTH] Enter");
3283
3291
  const config2 = configValidation();
3284
3292
  const userService = strapi.service("admin::user");
3285
- const tokenService = strapi.service("admin::token");
3293
+ strapi.service("admin::token");
3286
3294
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3287
3295
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
3288
3296
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback query code:", ctx?.query?.code);
@@ -3357,14 +3365,18 @@ async function microsoftSignInCallback(ctx) {
3357
3365
  } else {
3358
3366
  activateUser = dbUser;
3359
3367
  }
3360
- jwtToken = await tokenService.createToken(activateUser);
3368
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3369
+ id: activateUser.id
3370
+ });
3361
3371
  } else {
3362
3372
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user does not exist, creating it");
3363
3373
  const roles2 = await roleService.retrieveMicrosoftUserRoles(groupResponse, config2);
3364
3374
  const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
3365
3375
  activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
3366
3376
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
3367
- jwtToken = await tokenService.createToken(activateUser);
3377
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3378
+ id: activateUser.id
3379
+ });
3368
3380
  }
3369
3381
  oauthService.triggerSignInSuccess(activateUser);
3370
3382
  const nonce = v4();
@@ -3391,7 +3403,7 @@ async function microsoftLogout(ctx) {
3391
3403
  }
3392
3404
  async function microsoftTokenRenewal(ctx) {
3393
3405
  const userService = strapi.service("admin::user");
3394
- const tokenService = strapi.service("admin::token");
3406
+ strapi.service("admin::token");
3395
3407
  const config2 = configValidation();
3396
3408
  const { body } = ctx.request;
3397
3409
  const params = new URLSearchParams();
@@ -3415,21 +3427,10 @@ async function microsoftTokenRenewal(ctx) {
3415
3427
  }
3416
3428
  });
3417
3429
  const { mail } = userResponse?.data;
3418
- console.log("----mail----", mail);
3419
3430
  const dbUser = await userService.findOneByEmail(mail);
3420
- const jwtToken = await tokenService.createToken(dbUser);
3421
- console.log("----tokenService----", tokenService);
3422
- try {
3423
- console.log("----dbUser----", dbUser);
3424
- console.log("----dbUser----", JSON.stringify(dbUser));
3425
- const jwtToken2 = strapi.plugins["users-permissions"].services.jwt.issue({
3426
- id: dbUser.id
3427
- });
3428
- console.log("----jwtToken2----", jwtToken2);
3429
- console.log("----jwtToken2----", JSON.stringify(jwtToken2));
3430
- } catch (e2) {
3431
- console.log("----jwtToken2----, e", JSON.stringify(e2));
3432
- }
3431
+ const jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3432
+ id: dbUser.id
3433
+ });
3433
3434
  return ctx.send({ accessToken: jwtToken, refreshToken: tokenResponse.data.refresh_token });
3434
3435
  } catch (e2) {
3435
3436
  console.error(e2.message);
@@ -2965,7 +2965,7 @@ async function cognitoSignIn(ctx) {
2965
2965
  async function cognitoSignInCallback(ctx) {
2966
2966
  const config2 = configValidation$2();
2967
2967
  const userService = strapi.service("admin::user");
2968
- const tokenService = strapi.service("admin::token");
2968
+ strapi.service("admin::token");
2969
2969
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
2970
2970
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
2971
2971
  if (!ctx.query.code) {
@@ -3004,7 +3004,9 @@ async function cognitoSignInCallback(ctx) {
3004
3004
  let jwtToken;
3005
3005
  if (dbUser) {
3006
3006
  activateUser = dbUser;
3007
- jwtToken = await tokenService.createToken(dbUser);
3007
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3008
+ id: activateUser.id
3009
+ });
3008
3010
  } else {
3009
3011
  const cognitoRoles = await roleService.cognitoRoles();
3010
3012
  const roles2 = cognitoRoles && cognitoRoles["roles"] ? cognitoRoles["roles"].map((role2) => ({
@@ -3018,7 +3020,9 @@ async function cognitoSignInCallback(ctx) {
3018
3020
  defaultLocale,
3019
3021
  roles2
3020
3022
  );
3021
- jwtToken = await tokenService.createToken(activateUser);
3023
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3024
+ id: activateUser.id
3025
+ });
3022
3026
  await oauthService.triggerWebHook(activateUser);
3023
3027
  }
3024
3028
  oauthService.triggerSignInSuccess(activateUser);
@@ -3081,7 +3085,7 @@ async function customSignIn(ctx) {
3081
3085
  }
3082
3086
  async function customSignInCallback(ctx) {
3083
3087
  const userService = strapi.service("admin::user");
3084
- const tokenService = strapi.service("admin::token");
3088
+ strapi.service("admin::token");
3085
3089
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3086
3090
  const nonce = v4$1();
3087
3091
  try {
@@ -3093,7 +3097,9 @@ async function customSignInCallback(ctx) {
3093
3097
  }
3094
3098
  if (dbUser) {
3095
3099
  activateUser = dbUser;
3096
- jwtToken = await tokenService.createToken(dbUser);
3100
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3101
+ id: activateUser.id
3102
+ });
3097
3103
  }
3098
3104
  oauthService.triggerSignInSuccess(activateUser);
3099
3105
  const html = oauthService.renderSignUpSuccess(jwtToken, activateUser, nonce);
@@ -3162,7 +3168,7 @@ async function customSignInMfa(ctx) {
3162
3168
  }
3163
3169
  }
3164
3170
  async function customConfirmMfa(ctx) {
3165
- const tokenService = strapi.service("admin::token");
3171
+ strapi.service("admin::token");
3166
3172
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3167
3173
  const nonce = v4$1();
3168
3174
  const { code, id, uid } = ctx.query;
@@ -3184,7 +3190,9 @@ async function customConfirmMfa(ctx) {
3184
3190
  if (!otp2) {
3185
3191
  throw new Error("Invalid code");
3186
3192
  }
3187
- jwtToken = await tokenService.createToken(otp2.user);
3193
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3194
+ id: otp2.user.id
3195
+ });
3188
3196
  await strapi.query("plugin::strapi-custom-auth.mfaotp").delete({
3189
3197
  where: {
3190
3198
  id
@@ -3267,7 +3275,7 @@ async function microsoftSignInCallback(ctx) {
3267
3275
  console.log("[STRAPI-CUSTOM-AUTH] Enter");
3268
3276
  const config2 = configValidation();
3269
3277
  const userService = strapi.service("admin::user");
3270
- const tokenService = strapi.service("admin::token");
3278
+ strapi.service("admin::token");
3271
3279
  const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
3272
3280
  const roleService = strapi.plugin("strapi-custom-auth").service("role");
3273
3281
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback query code:", ctx?.query?.code);
@@ -3342,14 +3350,18 @@ async function microsoftSignInCallback(ctx) {
3342
3350
  } else {
3343
3351
  activateUser = dbUser;
3344
3352
  }
3345
- jwtToken = await tokenService.createToken(activateUser);
3353
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3354
+ id: activateUser.id
3355
+ });
3346
3356
  } else {
3347
3357
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user does not exist, creating it");
3348
3358
  const roles2 = await roleService.retrieveMicrosoftUserRoles(groupResponse, config2);
3349
3359
  const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
3350
3360
  activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
3351
3361
  console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
3352
- jwtToken = await tokenService.createToken(activateUser);
3362
+ jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3363
+ id: activateUser.id
3364
+ });
3353
3365
  }
3354
3366
  oauthService.triggerSignInSuccess(activateUser);
3355
3367
  const nonce = v4();
@@ -3376,7 +3388,7 @@ async function microsoftLogout(ctx) {
3376
3388
  }
3377
3389
  async function microsoftTokenRenewal(ctx) {
3378
3390
  const userService = strapi.service("admin::user");
3379
- const tokenService = strapi.service("admin::token");
3391
+ strapi.service("admin::token");
3380
3392
  const config2 = configValidation();
3381
3393
  const { body } = ctx.request;
3382
3394
  const params = new URLSearchParams();
@@ -3400,21 +3412,10 @@ async function microsoftTokenRenewal(ctx) {
3400
3412
  }
3401
3413
  });
3402
3414
  const { mail } = userResponse?.data;
3403
- console.log("----mail----", mail);
3404
3415
  const dbUser = await userService.findOneByEmail(mail);
3405
- const jwtToken = await tokenService.createToken(dbUser);
3406
- console.log("----tokenService----", tokenService);
3407
- try {
3408
- console.log("----dbUser----", dbUser);
3409
- console.log("----dbUser----", JSON.stringify(dbUser));
3410
- const jwtToken2 = strapi.plugins["users-permissions"].services.jwt.issue({
3411
- id: dbUser.id
3412
- });
3413
- console.log("----jwtToken2----", jwtToken2);
3414
- console.log("----jwtToken2----", JSON.stringify(jwtToken2));
3415
- } catch (e2) {
3416
- console.log("----jwtToken2----, e", JSON.stringify(e2));
3417
- }
3416
+ const jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
3417
+ id: dbUser.id
3418
+ });
3418
3419
  return ctx.send({ accessToken: jwtToken, refreshToken: tokenResponse.data.refresh_token });
3419
3420
  } catch (e2) {
3420
3421
  console.error(e2.message);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.29",
2
+ "version": "1.2.31",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {