Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pozylon committed Aug 27, 2024
1 parent 5ac6f7b commit 13a5060
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/resolvers/mutations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,5 @@ export default {
signPaymentProviderForCheckout,
),
deleteUser: acl(actions.deleteUser)(deleteUser),
deleteUserProductReviews,
deleteUserProductReviews: acl(actions.deleteUser)(deleteUserProductReviews),
};
1 change: 0 additions & 1 deletion packages/api/src/roles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const actions: Record<string, string> = [
'confirmMediaUpload',
'viewStatistics',
'deleteUser',
'deleteUserProductReviews',
].reduce((oldValue, actionValue) => {
const newValue = oldValue;
newValue[actionValue] = actionValue;
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/roles/loggedIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ export const loggedIn = (role: any, actions: Record<string, string>) => {
role.allow(actions.viewUserTokens, isMyself);
role.allow(actions.updateUser, isMyself);
role.allow(actions.deleteUser, isMyself);
role.allow(actions.deleteUserProductReviews, isMyself);
role.allow(actions.sendEmail, isOwnedEmailAddress);
role.allow(actions.viewOrder, isOwnedOrder);
role.allow(actions.updateOrder, isOwnedOrder);
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/schema/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ export default [
Remove user W3C push subscription object
"""
removePushSubscription(p256dh: String!): User!
deleteUser(userId: ID): Boolean
deleteUserProductReviews(userId: ID): Boolean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ export const configureProductReviewsModule = async ({
const deletionResult = await ProductReviews.deleteMany(selector);

await Promise.all(
productReviews.map(async (assortmentFilter) =>
productReviews.map(async (productReview) =>
emit('PRODUCT_REMOVE_REVIEW', {
assortmentFilterId: assortmentFilter._id,
productReviewId: productReview._id,
}),
),
);
Expand Down
6 changes: 1 addition & 5 deletions packages/core-users/src/module/configureUsersModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { configureUsersWebAuthnModule, UsersWebAuthnModule } from './configureUs
import * as pbkdf2 from './pbkdf2.js';
import * as sha256 from './sha256.js';
import type { Address, Contact } from '@unchainedshop/mongodb';
import crypto from 'crypto';

const isDate = (value) => {
const date = new Date(value);
Expand All @@ -27,10 +26,7 @@ const isDate = (value) => {

function maskString(value) {
if (isDate(value)) return value;
return crypto
.createHash('sha256')
.update(JSON.stringify([value, new Date().getTime()]))
.digest('hex');
return sha256.hash(JSON.stringify([value, new Date().getTime()]));
}

const maskUserPropertyValues = (user) => {
Expand Down

0 comments on commit 13a5060

Please sign in to comment.