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

fix(vue-demo): double opt in registration #1489

Merged
merged 7 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(vue-demo): double opt in registration
  • Loading branch information
mdanilowicz committed Nov 27, 2024
commit b67baf2b1d467480e2b8727e3fe5fb8c79049948
5 changes: 5 additions & 0 deletions .changeset/funny-chicken-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-pwa/composables-next": minor
---

Set user details when fully active
BrocksiNet marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions .changeset/light-games-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vue-demo-store": minor
---

Fix registration form for the double opt in registration flow
patzick marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 6 additions & 2 deletions packages/composables/src/useUser/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,12 @@ export function useUser(): UseUserReturn {
storefrontUrl: getStorefrontUrl(),
},
});
_user.value = data;
if (_user.value?.active) await refreshSessionContext();
// Set data when uses is active and not double opt in
BrocksiNet marked this conversation as resolved.
Show resolved Hide resolved
if (_user.value?.active && !_user.value?.doubleOptInRegistration) {
_user.value = data;
await refreshSessionContext();
BrocksiNet marked this conversation as resolved.
Show resolved Hide resolved
}

return data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,13 @@ const invokeSubmit = async () => {
try {
loading.value = true;
const response = await register(state);
if (response && response.active) router.push("/");
else if (response && !response.active) {
if (response && response.doubleOptInRegistration) {
Object.assign(state, JSON.parse(JSON.stringify(initialState)));
showDoubleOptInBox.value = true;
await nextTick();
doubleOptInBox.value?.scrollIntoView();
$v.value.$reset();
}
} else if (response && response.active) router.push("/");
BrocksiNet marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
if (error instanceof ApiClientError) {
const errors = resolveApiErrors(error.details.errors);
Expand Down
Loading