Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions docs/guides/function/managing-idp-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export default async (args) => {
});

return {
success: true,
userId: newUser.id,
userName: newUser.name,
};
Expand All @@ -238,7 +237,6 @@ export default async (args) => {
});

return {
success: true,
userId: newUser.id,
userName: newUser.name,
};
Expand All @@ -264,7 +262,6 @@ export default async (args) => {
});

return {
success: true,
userId: updatedUser.id,
disabled: updatedUser.disabled,
};
Expand All @@ -283,7 +280,6 @@ export default async (args) => {
});

return {
success: true,
userId: updatedUser.id,
};
};
Expand All @@ -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);
};
```

Expand All @@ -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,
};
};
```

Expand All @@ -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 };
};
```

Expand All @@ -361,17 +348,18 @@ 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) =>
idpClient.unenrollMfa({ userId: user.id, mfaFactorId }),
),
);

return { success: results.every(Boolean) };
const unenrolledFactorIds = user.mfaFactorIds.filter(
(_, index) => results[index],
);

return { unenrolledFactorIds };
};
```

Expand Down
Loading