Skip to content

Commit

Permalink
fix: do not delete locallogin if mergeInto is set
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Jan 16, 2025
1 parent 956fda2 commit 8aded0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,20 @@ export class DeleteUserService {
standMatchStorage ?? new BlStorage(StandMatchModel);
}

public async deleteUser(userDetailId: string): Promise<void> {
public async deleteUser(
userDetailId: string,
keepLocalLogin: boolean,
): Promise<void> {
const databaseQuery = this.queryBuilder.getDbQuery(
{ userDetail: userDetailId },
[{ fieldName: "userDetail", type: "object-id" }],
);
const users = await this.userStorage.getByQuery(databaseQuery);
for (const user of users) {
await this.userStorage.remove(user.id);
await this.removeLocalLogin(user.username);
if (!keepLocalLogin) {
await this.removeLocalLogin(user.username);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export class UserDetailDeleteHook extends Hook {
await this.checkActiveCustomerItems(id);
await this.checkActiveInvoices(id);
}
await this.deleteUserService.deleteUser(id);
await this.deleteUserService.deleteUser(
id,
(data?.mergeInto?.length ?? 0) > 0,
);

return true;
}
Expand Down

0 comments on commit 8aded0d

Please sign in to comment.