-
Notifications
You must be signed in to change notification settings - Fork 1
feat(account): add forgot password page #147
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
Merged
Merged
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
2b7260a
[POND-1] add first components
aheartforspinach 1eb5691
[POND-1] add wishlist icon in header
aheartforspinach a72d0b7
[POND-1] add shadcn
aheartforspinach 075d749
[POND-1] push broken stuff
aheartforspinach 9610f87
[POND-1] fix import topic
aheartforspinach 110fa93
[POND-1] add inner and outer
aheartforspinach 3d08d23
[POND-5] add button componentm extract login
aheartforspinach c42f5d1
[POND-5] add login form
aheartforspinach 1720218
[POND-5] remove dark variables, replace zinc with gray
aheartforspinach 20fd016
[POND-5] hunt error
aheartforspinach 4ab1f7e
[POND-5] fix issue
aheartforspinach 325841a
[POND-5] add auto animate
aheartforspinach 41dbea8
[POND-5] fix issues
aheartforspinach 9f1cd39
[POND-5] add password forgotten link
aheartforspinach 9c247bd
fix typo
aheartforspinach 3c705bd
install ducktory
aheartforspinach 6fba4a6
add ducktory
aheartforspinach 3d3366c
add more stories
aheartforspinach 1825783
fix accordion
aheartforspinach ca3f38e
update branch
aheartforspinach 484853d
adjust loogin
aheartforspinach 8ae730a
remove return
aheartforspinach a392ee6
revert change
aheartforspinach c9394dc
delete unneeded stuff
aheartforspinach 89d952f
use formatLink
aheartforspinach 9d15c28
Merge remote-tracking branch 'origin/release/v0.2' into feature/POND-…
aheartforspinach b4431f4
fix localepath
aheartforspinach 92d4e5d
[POND-10]: add recover password page
MorennMcFly 9df1023
[POND-10]: add documentation
MorennMcFly 63b6495
Merge branch 'release/v0.2' into feature/POND-10-forgot-password
MorennMcFly 51fc324
Apply suggestions from code review
MorennMcFly 8a17584
[POND-10]: add paragraphs and a slot in template, update docs
MorennMcFly 649e0ef
[POND-10]: update docs
MorennMcFly 9659066
Merge branch 'refs/heads/release/v0.2' into feature/POND-10-forgot-pa…
MorennMcFly 1fb156d
[POND-10]: make email and password snippets more generic
MorennMcFly d8e26bd
Merge branch 'refs/heads/release/v0.2' into feature/POND-10-forgot-pa…
MorennMcFly ad10e7c
[POND-11]: fix indentation
MorennMcFly 8ad4f72
Merge branch 'release/v0.2' into feature/POND-10-forgot-password
MorennMcFly cb446e1
[POND-10]: resolve docs conflicts
MorennMcFly afc8343
[POND-10]: close login dialog on navigation to recover page
MorennMcFly ef5e1c6
Merge branch 'release/v0.2' into feature/POND-10-forgot-password
MorennMcFly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script setup lang="ts"> | ||
import type { RecoverData } from './AccountRecoverInner.vue'; | ||
|
||
const isLoading = ref(false); | ||
const showSuccessMessage = ref(false); | ||
|
||
const customerStore = useCustomerStore(); | ||
const { getStorefrontUrl } = useInternationalization(); | ||
|
||
const recover = async (recoverData: RecoverData) => { | ||
isLoading.value = true; | ||
|
||
try { | ||
await customerStore.resetPassword({ | ||
...recoverData, | ||
storefrontUrl: getStorefrontUrl(), | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
} catch (error) { | ||
// catch but do nothing | ||
} finally { | ||
showSuccessMessage.value = true; | ||
isLoading.value = false; | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<AccountRecoverInner | ||
:is-loading="isLoading" | ||
:show-success-message="showSuccessMessage" | ||
@recover="(recoverData: RecoverData) => recover(recoverData)" | ||
/> | ||
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<script setup lang="ts"> | ||
import * as z from 'zod'; | ||
const { t } = useI18n(); | ||
|
||
withDefaults( | ||
defineProps<{ | ||
isLoading?: boolean; | ||
showSuccessMessage?: boolean; | ||
}>(), | ||
{ | ||
isLoading: false, | ||
showSuccessMessage: false, | ||
}, | ||
); | ||
|
||
const emits = defineEmits<{ | ||
recover: [recoverData: RecoverData]; | ||
}>(); | ||
|
||
const schema = z.object({ | ||
email: z | ||
.string({ | ||
required_error: t('account.email.error'), | ||
}) | ||
.email(), | ||
}); | ||
|
||
export type RecoverData = z.infer<typeof schema>; | ||
|
||
const recover = (recoverData: RecoverData) => { | ||
emits('recover', recoverData); | ||
}; | ||
</script> | ||
|
||
<template> | ||
aheartforspinach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<slot name="wrapper"> | ||
<div v-auto-animate> | ||
<slot name="success-message"> | ||
<template v-if="showSuccessMessage"> | ||
<UiAlert variant="successful" class="mb-4 flex gap-4"> | ||
<slot name="alert-icon"> | ||
<Icon name="mdi:check" class="size-4 shrink-0" /> | ||
</slot> | ||
|
||
<div> | ||
<UiAlertTitle>{{ $t('account.recover.successHeader') }}</UiAlertTitle> | ||
<UiAlertDescription> | ||
{{ $t('account.recover.successMessage') }} | ||
</UiAlertDescription> | ||
</div> | ||
</UiAlert> | ||
</template> | ||
</slot> | ||
|
||
<slot name="header"> | ||
<h1 class="text-lg font-semibold">{{ $t('account.recover.header') }}</h1> | ||
<hr> | ||
</slot> | ||
|
||
<slot name="info-text"> | ||
<p class="pb-4 pt-2 text-sm">{{ $t('account.recover.information') }}</p> | ||
</slot> | ||
|
||
<slot name="form"> | ||
<UiAutoForm | ||
class="space-y-6" | ||
:schema="schema" | ||
:field-config="{ | ||
email: { | ||
label: $t('account.email.label'), | ||
inputProps: { | ||
type: 'email', | ||
placeholder: $t('account.email.placeholder'), | ||
}, | ||
} | ||
}" | ||
@submit="recover" | ||
> | ||
<slot name="buttons"> | ||
<div class="flex flex-wrap gap-4"> | ||
<slot name="back-button"> | ||
<UiButton variant="outline" class="w-fit grow sm:grow-0"> | ||
<NuxtLinkLocale to="/account/login">{{ $t('account.recover.backButton') }}</NuxtLinkLocale> | ||
</UiButton> | ||
</slot> | ||
|
||
<slot name="submit-button"> | ||
<UiButton type="submit" :is-loading="isLoading" class="min-w-52 grow"> | ||
{{ $t('account.recover.submitButton') }} | ||
</UiButton> | ||
</slot> | ||
</div> | ||
</slot> | ||
</UiAutoForm> | ||
</slot> | ||
</div> | ||
</slot> | ||
</template> | ||
MorennMcFly marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Account management | ||
|
||
## Account Recovery | ||
|
||
The **Account Recovery** page provides users with a secure way to initiate a password reset via email. When a user submits an email address: | ||
|
||
- If the email is **registered**, a recovery link is sent and a generic success message is displayed. | ||
- If the email is **not registered**, a generic success message is still displayed to prevent account enumeration. | ||
|
||
### Component Structure | ||
|
||
This page is composed of layered components: | ||
|
||
1. **`pages/account/recover.vue`** – wraps the recovery component in a responsive layout. | ||
|
||
2. **`components/account/AccountRecover.vue`** – manages the logic, loading state, and message display. | ||
|
||
3. **`components/account/AccountRecoverInner.vue`** – provides the form UI and emits the form submission event. Customizable via **named slots**. | ||
|
||
--- | ||
|
||
### Named Slots | ||
|
||
The `AccountRecoverInner.vue` component exposes several named slots for UI customization: | ||
|
||
| Slot Name | Description | | ||
|-------------------|--------------------------------------------------------------| | ||
| `wrapper` | Wraps the component, including form and messages | | ||
| `success-message` | Overrides the default success alert | | ||
| `alert-icon` | Overrides the default success alert icon | | ||
| `header` | Overrides the default heading | | ||
| `info-text` | Overrides the informational text displayed below the heading | | ||
| `form` | Wraps the form | | ||
| `buttons` | Wraps the buttons | | ||
| `back-button` | Overrides the back to login button | | ||
| `submit-button` | Overrides the submit button | | ||
|
||
--- | ||
|
||
### Props | ||
|
||
`AccountRecoverInner.vue` accepts two optional props: | ||
|
||
| Prop Name | Type | Description | | ||
|----------------------|-----------|---------------------------------------------| | ||
| `isLoading` | `boolean` | Controls a loading spinner on submit button | | ||
| `showSuccessMessage` | `boolean` | Controls whether the success message shows | | ||
|
||
--- | ||
|
||
### Events | ||
|
||
| Event Name | Payload | Description | | ||
|------------|-----------------------|----------------------------------| | ||
| `recover` | `{ email: string }` | Emitted when form is submitted | | ||
|
||
--- | ||
|
||
### Usage Example: Custom Header & Message | ||
|
||
```vue | ||
<AccountRecoverInner> | ||
<template #header> | ||
<h1 class="text-2xl font-bold text-primary">Reset Your Password</h1> | ||
<p class="text-sm text-gray-500">Enter your email to receive a recovery link.</p> | ||
<hr class="my-4" /> | ||
</template> | ||
|
||
<template #success-message> | ||
<UiAlert variant="successful" class="mb-4"> | ||
<Icon name="mdi:check" class="mr-2" /> | ||
<span>We've sent a link to your inbox—check your email!</span> | ||
</UiAlert> | ||
</template> | ||
</AccountRecoverInner> | ||
``` | ||
|
||
### Technical Notes | ||
|
||
This component uses the `resetPassword` method from the `useCustomerPassword` composable under the hood. | ||
|
||
You can learn more about the `useCustomerPassword` composable in the Shopware Frontends documentation: [Shopware Frontends – useCustomerPassword](https://frontends.shopware.com/packages/composables/useCustomerPassword.html) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template> | ||
<div class="container relative flex justify-center py-4"> | ||
<div class="w-full md:w-2/3 xl:w-1/2"> | ||
<AccountRecover /> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.