Skip to content

Commit 5990057

Browse files
authored
Merge pull request #1697 from Shelf-nu/1684-bug-deleting-an-account-should-destroy-some-adjecent-data
bug: deleting an account should destroy some adjecent data
2 parents e10de22 + 9a4c6c7 commit 5990057

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

app/modules/user/service.server.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,12 +1033,27 @@ export async function softDeleteUser(id: User["id"]) {
10331033
await deleteProfilePicture({ url: user.profilePicture });
10341034
}
10351035

1036+
/** Delete the auth user. This should also destroy all their current sessions */
1037+
const { error } = await getSupabaseAdmin().auth.admin.deleteUser(
1038+
user.id,
1039+
true // Soft delete
1040+
);
1041+
10361042
/** Send an email to the user that their request has been completed */
10371043
void sendEmail({
10381044
to: user.email,
10391045
subject: "Your account has been deleted",
10401046
text: `Your shelf account has been deleted. \n\n Kind regards, \n Shelf Team\n\n`,
10411047
});
1048+
1049+
if (error) {
1050+
throw new ShelfError({
1051+
cause: error,
1052+
message: "Failed to delete Auth user",
1053+
additionalData: { id, error },
1054+
label: "Auth",
1055+
});
1056+
}
10421057
} catch (cause) {
10431058
if (
10441059
cause instanceof PrismaClientKnownRequestError &&

0 commit comments

Comments
 (0)