File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1033,12 +1033,27 @@ export async function softDeleteUser(id: User["id"]) {
1033
1033
await deleteProfilePicture ( { url : user . profilePicture } ) ;
1034
1034
}
1035
1035
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
+
1036
1042
/** Send an email to the user that their request has been completed */
1037
1043
void sendEmail ( {
1038
1044
to : user . email ,
1039
1045
subject : "Your account has been deleted" ,
1040
1046
text : `Your shelf account has been deleted. \n\n Kind regards, \n Shelf Team\n\n` ,
1041
1047
} ) ;
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
+ }
1042
1057
} catch ( cause ) {
1043
1058
if (
1044
1059
cause instanceof PrismaClientKnownRequestError &&
You can’t perform that action at this time.
0 commit comments