strapi-custom-auth 1.2.38 → 1.2.39
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/server/index.js +35 -7
- package/dist/server/index.mjs +35 -7
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -3019,7 +3019,11 @@ async function cognitoSignInCallback(ctx) {
|
|
|
3019
3019
|
let jwtToken;
|
|
3020
3020
|
if (dbUser) {
|
|
3021
3021
|
activateUser = dbUser;
|
|
3022
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3022
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3023
|
+
userId: `${dbUser.id}`,
|
|
3024
|
+
type: "access",
|
|
3025
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3026
|
+
});
|
|
3023
3027
|
} else {
|
|
3024
3028
|
const cognitoRoles = await roleService.cognitoRoles();
|
|
3025
3029
|
const roles2 = cognitoRoles && cognitoRoles["roles"] ? cognitoRoles["roles"].map((role2) => ({
|
|
@@ -3033,7 +3037,11 @@ async function cognitoSignInCallback(ctx) {
|
|
|
3033
3037
|
defaultLocale,
|
|
3034
3038
|
roles2
|
|
3035
3039
|
);
|
|
3036
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3040
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3041
|
+
userId: `${activateUser.id}`,
|
|
3042
|
+
type: "access",
|
|
3043
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3044
|
+
});
|
|
3037
3045
|
await oauthService.triggerWebHook(activateUser);
|
|
3038
3046
|
}
|
|
3039
3047
|
oauthService.triggerSignInSuccess(activateUser);
|
|
@@ -3108,7 +3116,11 @@ async function customSignInCallback(ctx) {
|
|
|
3108
3116
|
}
|
|
3109
3117
|
if (dbUser) {
|
|
3110
3118
|
activateUser = dbUser;
|
|
3111
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3119
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3120
|
+
userId: `${dbUser.id}`,
|
|
3121
|
+
type: "access",
|
|
3122
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3123
|
+
});
|
|
3112
3124
|
}
|
|
3113
3125
|
oauthService.triggerSignInSuccess(activateUser);
|
|
3114
3126
|
const html = oauthService.renderSignUpSuccess(jwtToken, activateUser, nonce);
|
|
@@ -3199,7 +3211,11 @@ async function customConfirmMfa(ctx) {
|
|
|
3199
3211
|
if (!otp2) {
|
|
3200
3212
|
throw new Error("Invalid code");
|
|
3201
3213
|
}
|
|
3202
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3214
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3215
|
+
userId: `${otp2.user.id}`,
|
|
3216
|
+
type: "access",
|
|
3217
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3218
|
+
});
|
|
3203
3219
|
await strapi.query("plugin::strapi-custom-auth.mfaotp").delete({
|
|
3204
3220
|
where: {
|
|
3205
3221
|
id
|
|
@@ -3357,14 +3373,22 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3357
3373
|
} else {
|
|
3358
3374
|
activateUser = dbUser;
|
|
3359
3375
|
}
|
|
3360
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3376
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3377
|
+
userId: `${activateUser.id}`,
|
|
3378
|
+
type: "access",
|
|
3379
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3380
|
+
});
|
|
3361
3381
|
} else {
|
|
3362
3382
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user does not exist, creating it");
|
|
3363
3383
|
const roles2 = await roleService.retrieveMicrosoftUserRoles(groupResponse, config2);
|
|
3364
3384
|
const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
|
|
3365
3385
|
activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
|
|
3366
3386
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
|
|
3367
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3387
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3388
|
+
userId: `${activateUser.id}`,
|
|
3389
|
+
type: "access",
|
|
3390
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3391
|
+
});
|
|
3368
3392
|
}
|
|
3369
3393
|
oauthService.triggerSignInSuccess(activateUser);
|
|
3370
3394
|
const nonce = v4();
|
|
@@ -3416,7 +3440,11 @@ async function microsoftTokenRenewal(ctx) {
|
|
|
3416
3440
|
});
|
|
3417
3441
|
const { mail } = userResponse?.data;
|
|
3418
3442
|
const dbUser = await userService.findOneByEmail(mail);
|
|
3419
|
-
const jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3443
|
+
const jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3444
|
+
userId: `${dbUser.id}`,
|
|
3445
|
+
type: "access",
|
|
3446
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3447
|
+
});
|
|
3420
3448
|
return ctx.send({ accessToken: jwtToken, refreshToken: tokenResponse.data.refresh_token });
|
|
3421
3449
|
} catch (e2) {
|
|
3422
3450
|
console.error(e2.message);
|
package/dist/server/index.mjs
CHANGED
|
@@ -3004,7 +3004,11 @@ async function cognitoSignInCallback(ctx) {
|
|
|
3004
3004
|
let jwtToken;
|
|
3005
3005
|
if (dbUser) {
|
|
3006
3006
|
activateUser = dbUser;
|
|
3007
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3007
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3008
|
+
userId: `${dbUser.id}`,
|
|
3009
|
+
type: "access",
|
|
3010
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3011
|
+
});
|
|
3008
3012
|
} else {
|
|
3009
3013
|
const cognitoRoles = await roleService.cognitoRoles();
|
|
3010
3014
|
const roles2 = cognitoRoles && cognitoRoles["roles"] ? cognitoRoles["roles"].map((role2) => ({
|
|
@@ -3018,7 +3022,11 @@ async function cognitoSignInCallback(ctx) {
|
|
|
3018
3022
|
defaultLocale,
|
|
3019
3023
|
roles2
|
|
3020
3024
|
);
|
|
3021
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3025
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3026
|
+
userId: `${activateUser.id}`,
|
|
3027
|
+
type: "access",
|
|
3028
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3029
|
+
});
|
|
3022
3030
|
await oauthService.triggerWebHook(activateUser);
|
|
3023
3031
|
}
|
|
3024
3032
|
oauthService.triggerSignInSuccess(activateUser);
|
|
@@ -3093,7 +3101,11 @@ async function customSignInCallback(ctx) {
|
|
|
3093
3101
|
}
|
|
3094
3102
|
if (dbUser) {
|
|
3095
3103
|
activateUser = dbUser;
|
|
3096
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3104
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3105
|
+
userId: `${dbUser.id}`,
|
|
3106
|
+
type: "access",
|
|
3107
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3108
|
+
});
|
|
3097
3109
|
}
|
|
3098
3110
|
oauthService.triggerSignInSuccess(activateUser);
|
|
3099
3111
|
const html = oauthService.renderSignUpSuccess(jwtToken, activateUser, nonce);
|
|
@@ -3184,7 +3196,11 @@ async function customConfirmMfa(ctx) {
|
|
|
3184
3196
|
if (!otp2) {
|
|
3185
3197
|
throw new Error("Invalid code");
|
|
3186
3198
|
}
|
|
3187
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3199
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3200
|
+
userId: `${otp2.user.id}`,
|
|
3201
|
+
type: "access",
|
|
3202
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3203
|
+
});
|
|
3188
3204
|
await strapi.query("plugin::strapi-custom-auth.mfaotp").delete({
|
|
3189
3205
|
where: {
|
|
3190
3206
|
id
|
|
@@ -3342,14 +3358,22 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3342
3358
|
} else {
|
|
3343
3359
|
activateUser = dbUser;
|
|
3344
3360
|
}
|
|
3345
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3361
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3362
|
+
userId: `${activateUser.id}`,
|
|
3363
|
+
type: "access",
|
|
3364
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3365
|
+
});
|
|
3346
3366
|
} else {
|
|
3347
3367
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user does not exist, creating it");
|
|
3348
3368
|
const roles2 = await roleService.retrieveMicrosoftUserRoles(groupResponse, config2);
|
|
3349
3369
|
const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
|
|
3350
3370
|
activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
|
|
3351
3371
|
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
|
|
3352
|
-
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3372
|
+
jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3373
|
+
userId: `${activateUser.id}`,
|
|
3374
|
+
type: "access",
|
|
3375
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3376
|
+
});
|
|
3353
3377
|
}
|
|
3354
3378
|
oauthService.triggerSignInSuccess(activateUser);
|
|
3355
3379
|
const nonce = v4();
|
|
@@ -3401,7 +3425,11 @@ async function microsoftTokenRenewal(ctx) {
|
|
|
3401
3425
|
});
|
|
3402
3426
|
const { mail } = userResponse?.data;
|
|
3403
3427
|
const dbUser = await userService.findOneByEmail(mail);
|
|
3404
|
-
const jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3428
|
+
const jwtToken = strapi.plugins["users-permissions"].services.jwt.issue({
|
|
3429
|
+
userId: `${dbUser.id}`,
|
|
3430
|
+
type: "access",
|
|
3431
|
+
sessionId: "306b9b90ed47a1f9297ec25f05b07e05"
|
|
3432
|
+
});
|
|
3405
3433
|
return ctx.send({ accessToken: jwtToken, refreshToken: tokenResponse.data.refresh_token });
|
|
3406
3434
|
} catch (e2) {
|
|
3407
3435
|
console.error(e2.message);
|
package/package.json
CHANGED