Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-allow guest contributions with verified accounts for trusted hosts #9897

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion server/graphql/v1/mutations/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ export async function createOrder(order, req) {
}

const guestInfoInput = { ...order.guestInfo, currency: order.currency };
const guestProfile = await getOrCreateGuestProfile(guestInfoInput, creationRequest);
const guestOptions = { throwIfAVerifiedAccountExists: !host.data?.isTrustedHost };
const guestProfile = await getOrCreateGuestProfile(guestInfoInput, creationRequest, guestOptions);
if (!canUseFeature(guestProfile.user, FEATURE.ORDER)) {
throw new FeatureNotAllowedForUser();
}
Expand Down
3 changes: 2 additions & 1 deletion server/lib/guest-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type UserCreationRequest = {
export const getOrCreateGuestProfile = async (
{ email, name, legalName, location, currency }: UserInfoInput,
creationRequest: UserCreationRequest = null,
{ throwIfAVerifiedAccountExists = true } = {},
): Promise<GuestProfileDetails> => {
const emailConfirmationToken = crypto.randomBytes(48).toString('hex');

Expand Down Expand Up @@ -83,7 +84,7 @@ export const getOrCreateGuestProfile = async (
transaction,
include: [{ association: 'location' }],
});
if (user.confirmedAt) {
if (user.confirmedAt && throwIfAVerifiedAccountExists) {
throw new BadRequest('There is already an account associated with this email, please sign in.');
}

Expand Down
Loading