diff --git a/docs/guides/function/managing-idp-users.md b/docs/guides/function/managing-idp-users.md index 53a774b..d605ad2 100644 --- a/docs/guides/function/managing-idp-users.md +++ b/docs/guides/function/managing-idp-users.md @@ -214,7 +214,6 @@ export default async (args) => { }); return { - success: true, userId: newUser.id, userName: newUser.name, }; @@ -238,7 +237,6 @@ export default async (args) => { }); return { - success: true, userId: newUser.id, userName: newUser.name, }; @@ -264,7 +262,6 @@ export default async (args) => { }); return { - success: true, userId: updatedUser.id, disabled: updatedUser.disabled, }; @@ -283,7 +280,6 @@ export default async (args) => { }); return { - success: true, userId: updatedUser.id, }; }; @@ -297,11 +293,7 @@ The `deleteUser` method deletes a user by their ID. export default async (args) => { const idpClient = new tailor.idp.Client({ namespace: args.namespaceName }); - const success = await idpClient.deleteUser(args.userId); - - return { - success: success, - }; + return idpClient.deleteUser(args.userId); }; ``` @@ -313,16 +305,12 @@ The `sendPasswordResetEmail` method sends a password reset email to a user. This export default async (args) => { const idpClient = new tailor.idp.Client({ namespace: args.namespaceName }); - const success = await idpClient.sendPasswordResetEmail({ + return idpClient.sendPasswordResetEmail({ userId: args.userId, redirectUri: "https://your-app.com/reset-password-complete", fromName: "My App Support", subject: "Password Reset for Your My App Account", }); - - return { - success: success, - }; }; ``` @@ -346,11 +334,10 @@ To remove one specific factor: ```js export default async (args) => { const idpClient = new tailor.idp.Client({ namespace: args.namespaceName }); - const success = await idpClient.unenrollMfa({ + return idpClient.unenrollMfa({ userId: args.userId, mfaFactorId: args.mfaFactorId, }); - return { success }; }; ``` @@ -361,9 +348,6 @@ export default async (args) => { const idpClient = new tailor.idp.Client({ namespace: args.namespaceName }); const user = await idpClient.user(args.userId); - if (!user.mfaEnrolled) { - return { success: false, reason: "User has no enrolled MFA factors" }; - } const results = await Promise.all( user.mfaFactorIds.map((mfaFactorId) => @@ -371,7 +355,11 @@ export default async (args) => { ), ); - return { success: results.every(Boolean) }; + const unenrolledFactorIds = user.mfaFactorIds.filter( + (_, index) => results[index], + ); + + return { unenrolledFactorIds }; }; ```