-
Notifications
You must be signed in to change notification settings - Fork 703
[6.x] Port CP set-password and verify-email into Inertia #19172
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
83 changes: 83 additions & 0 deletions
83
resources/js/modules/auth/components/set-password/set-password-form.ts
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 @@ | ||
| import {html, LitElement, nothing} from 'lit'; | ||
| import {property, state} from 'lit/decorators.js'; | ||
| import {t} from '@craftcms/cp'; | ||
| import componentStyles from '../login/login-form.styles.js'; | ||
|
|
||
| /** | ||
| * @summary Full-page set-password form. | ||
| * @since 6.0 | ||
| */ | ||
| export default class CraftSetPasswordForm extends LitElement { | ||
| static override styles = [componentStyles]; | ||
|
|
||
| @property() action = ''; | ||
| @property() uid = ''; | ||
| @property() code = ''; | ||
| @property({attribute: 'initial-error'}) initialError = ''; | ||
| @property({type: Boolean, attribute: 'new-user'}) newUser = false; | ||
|
|
||
| @state() private _busy = false; | ||
|
|
||
| #passwordLabel() { | ||
| return this.newUser ? t('Choose a password') : t('Choose a new password'); | ||
| } | ||
|
|
||
| #onSubmit() { | ||
| this._busy = true; | ||
| } | ||
|
|
||
| override render() { | ||
| return html` | ||
| <craft-pane> | ||
| <form | ||
| class="auth-form" | ||
| method="post" | ||
| action="${this.action}" | ||
| accept-charset="UTF-8" | ||
| @submit="${this.#onSubmit}" | ||
| > | ||
| <input type="hidden" name="uid" value="${this.uid}" /> | ||
| <input type="hidden" name="code" value="${this.code}" /> | ||
|
|
||
| <craft-field-group> | ||
| <craft-input-password | ||
| label="${this.#passwordLabel()}" | ||
| id="newPassword" | ||
| name="newPassword" | ||
| autocomplete="new-password" | ||
| required | ||
| autofocus | ||
| ></craft-input-password> | ||
| </craft-field-group> | ||
|
|
||
| <div class="auth-form__actions"> | ||
| <craft-button | ||
| type="submit" | ||
| variant="accent" | ||
| ?loading="${this._busy}" | ||
| style="width: 100%" | ||
| > | ||
| ${t('Set Password')} | ||
| </craft-button> | ||
| </div> | ||
| </form> | ||
|
|
||
| ${this.initialError | ||
| ? html`<craft-callout class="auth-form__error" variant="danger" | ||
| >${this.initialError}</craft-callout | ||
| >` | ||
| : nothing} | ||
| </craft-pane> | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| if (!customElements.get('craft-set-password-form')) { | ||
| customElements.define('craft-set-password-form', CraftSetPasswordForm); | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'craft-set-password-form': CraftSetPasswordForm; | ||
| } | ||
| } |
69 changes: 69 additions & 0 deletions
69
resources/js/modules/auth/components/verify-email/verify-email-form.ts
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,69 @@ | ||
| import {html, LitElement, nothing} from 'lit'; | ||
| import {property, state} from 'lit/decorators.js'; | ||
| import {t} from '@craftcms/cp'; | ||
| import componentStyles from '../login/login-form.styles.js'; | ||
|
|
||
| /** | ||
| * @summary Full-page verify-email form. | ||
| * @since 6.0 | ||
| */ | ||
| export default class CraftVerifyEmailForm extends LitElement { | ||
| static override styles = [componentStyles]; | ||
|
|
||
| @property() action = ''; | ||
| @property() uid = ''; | ||
| @property() code = ''; | ||
| @property({attribute: 'initial-error'}) initialError = ''; | ||
|
|
||
| @state() private _busy = false; | ||
|
|
||
| #onSubmit() { | ||
| this._busy = true; | ||
| } | ||
|
|
||
| override render() { | ||
| return html` | ||
| <craft-pane> | ||
| <form | ||
| class="auth-form" | ||
| method="post" | ||
| action="${this.action}" | ||
| accept-charset="UTF-8" | ||
| @submit="${this.#onSubmit}" | ||
| > | ||
| <input type="hidden" name="uid" value="${this.uid}" /> | ||
| <input type="hidden" name="code" value="${this.code}" /> | ||
|
|
||
| <h2 class="auth-form__heading">${t('Verify your email address')}</h2> | ||
|
|
||
| <div class="auth-form__actions"> | ||
| <craft-button | ||
| type="submit" | ||
| variant="accent" | ||
| ?loading="${this._busy}" | ||
| style="width: 100%" | ||
| > | ||
| ${t('Verify')} | ||
| </craft-button> | ||
| </div> | ||
| </form> | ||
|
|
||
| ${this.initialError | ||
| ? html`<craft-callout class="auth-form__error" variant="danger" | ||
| >${this.initialError}</craft-callout | ||
| >` | ||
| : nothing} | ||
| </craft-pane> | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| if (!customElements.get('craft-verify-email-form')) { | ||
| customElements.define('craft-verify-email-form', CraftVerifyEmailForm); | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'craft-verify-email-form': CraftVerifyEmailForm; | ||
| } | ||
| } |
|
riasvdv marked this conversation as 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <script setup lang="ts"> | ||
| import {computed} from 'vue'; | ||
| import {t} from '@craftcms/cp'; | ||
| import {usePage} from '@inertiajs/vue3'; | ||
| import AuthBase from '@/common/layouts/AuthBase.vue'; | ||
| import {store} from '@actions/Auth/SetPasswordController'; | ||
| import '@/modules/auth/components/set-password/set-password-form.js'; | ||
|
|
||
| const props = defineProps<{ | ||
| uid: string; | ||
| code: string; | ||
| newUser: boolean; | ||
| }>(); | ||
|
|
||
| const page = usePage<{ | ||
| errors?: Record<string, string>; | ||
| }>(); | ||
|
|
||
| const title = computed(() => | ||
| props.newUser ? t('Set Your Password') : t('Set Your New Password') | ||
| ); | ||
|
|
||
| const action = computed( | ||
| () => store(undefined, {query: {uid: props.uid, code: props.code}}).url | ||
| ); | ||
| </script> | ||
|
|
||
| <template> | ||
| <AuthBase :title="title"> | ||
| <craft-set-password-form | ||
| :action="action" | ||
| :uid="uid" | ||
| :code="code" | ||
| :initial-error="page.props.errors?.newPassword" | ||
| :new-user="newUser ? '' : null" | ||
| ></craft-set-password-form> | ||
| </AuthBase> | ||
| </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,36 @@ | ||
| <script setup lang="ts"> | ||
| import {t} from '@craftcms/cp'; | ||
| import {computed} from 'vue'; | ||
| import {usePage} from '@inertiajs/vue3'; | ||
| import AuthBase from '@/common/layouts/AuthBase.vue'; | ||
| import {store} from '@actions/Auth/VerifyEmailController'; | ||
| import '@/modules/auth/components/verify-email/verify-email-form.js'; | ||
|
|
||
| const props = defineProps<{ | ||
| uid: string; | ||
| code: string; | ||
| }>(); | ||
|
|
||
| const page = usePage<{ | ||
| errors?: Record<string, string>; | ||
| }>(); | ||
|
|
||
| const action = computed( | ||
| () => store(undefined, {query: {uid: props.uid, code: props.code}}).url | ||
| ); | ||
|
|
||
| const initialError = computed( | ||
| () => page.props.errors?.code ?? page.props.errors?.uid | ||
| ); | ||
| </script> | ||
|
|
||
| <template> | ||
| <AuthBase :title="t('Verify your email address')"> | ||
| <craft-verify-email-form | ||
| :action="action" | ||
| :uid="uid" | ||
| :code="code" | ||
| :initial-error="initialError" | ||
| ></craft-verify-email-form> | ||
| </AuthBase> | ||
| </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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably rename this file to
auth-form.styles.tsand move it out of theloginfolder