Skip to content

Commit

Permalink
Merge pull request #25 from beromir/fix/21-show-form-errors-on-regist…
Browse files Browse the repository at this point in the history
…er-page

[FIX] Show form errors on the authentication pages
  • Loading branch information
beromir authored Aug 15, 2022
2 parents 3597357 + 3b120b8 commit 0c78ec8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion resources/js/Jetstream/InputError.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</script>

{#if !isUndefined(message)}
<p class={['text-sm text-red-600', $$restProps.class].join(' ').trim()}>
<p class={['mt-1 text-sm text-red-600', $$restProps.class].join(' ').trim()}>
{message}
</p>
{/if}
7 changes: 3 additions & 4 deletions resources/js/Pages/Auth/Login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import JetInput from '@/Jetstream/Input.svelte'
import JetCheckbox from '@/Jetstream/Checkbox.svelte'
import JetLabel from '@/Jetstream/Label.svelte'
import ValidationErrors from "@/Jetstream/ValidationErrors.svelte";
import JetInputError from '@/Jetstream/InputError.svelte'
import {route} from '@/utils';
export let canResetPassword;
Expand All @@ -35,19 +35,18 @@
<JetAuthenticationCard>
<JetAuthenticationCardLogo slot="logo"/>

<ValidationErrors class="mt-4" errors={$form.errors} hasErrors={$form.hasErrors}/>

<form on:submit|preventDefault={login}>
<div>
<JetLabel id="email" label="Email"/>
<JetInput bind:value={$form.email} id="email" type="email" class="mt-1 block w-full" required autofocus/>
{#if $form.errors.email}{$form.errors.email}{/if}
<JetInputError message={$form.errors.email}/>
</div>

<div class="mt-4">
<JetLabel id="password" label="Password"/>
<JetInput bind:value={$form.password} id="password" type="password" class="mt-1 block w-full" required
autocomplete="current-password"/>
<JetInputError message={$form.errors.password}/>
</div>

<div class="block mt-4">
Expand Down
9 changes: 5 additions & 4 deletions resources/js/Pages/Auth/Register.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
import JetAuthenticationCardLogo from '@/Jetstream/AuthenticationCardLogo.svelte'
import JetButton from '@/Jetstream/Button.svelte'
import JetInput from '@/Jetstream/Input.svelte'
// import JetCheckbox from '@/Jetstream/Checkbox.svelte'
import JetInputError from '@/Jetstream/InputError.svelte'
import JetLabel from '@/Jetstream/Label.svelte'
import JetValidationErrors from '@/Jetstream/ValidationErrors.svelte'
$title = 'Register';
Expand All @@ -34,30 +33,32 @@
<JetAuthenticationCard>
<JetAuthenticationCardLogo slot="logo"/>

<JetValidationErrors class="mb-4"/>

<form on:submit|preventDefault={register}>
<div>
<JetLabel id="name" label="Name"/>
<JetInput id="name" class="mt-1 block w-full" bind:value={$form.name} required autofocus
autocomplete="name"/>
<JetInputError message={$form.errors.name}/>
</div>

<div class="mt-4">
<JetLabel id="email" label="Email"/>
<JetInput id="email" type="email" class="mt-1 block w-full" bind:value={$form.email} required/>
<JetInputError message={$form.errors.email}/>
</div>

<div class="mt-4">
<JetLabel id="password" label="Password"/>
<JetInput id="password" type="password" class="mt-1 block w-full" bind:value={$form.password} required
autocomplete="new-password"/>
<JetInputError message={$form.errors.password}/>
</div>

<div class="mt-4">
<JetLabel id="password_confirmation" label="Confirm Password"/>
<JetInput id="password_confirmation" type="password" class="mt-1 block w-full"
bind:value={$form.password_confirmation} required autocomplete="new-password"/>
<JetInputError message={$form.errors.password_confirmation}/>
</div>

<!--
Expand Down
6 changes: 3 additions & 3 deletions resources/js/Pages/Auth/TwoFactorChallenge.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import JetButton from '@/Jetstream/Button.svelte';
import JetInput from '@/Jetstream/Input.svelte';
import JetLabel from '@/Jetstream/Label.svelte';
import JetValidationErrors from '@/Jetstream/ValidationErrors.svelte';
import JetInputError from '@/Jetstream/InputError.svelte';
import {useForm} from "@inertiajs/inertia-svelte";
import {tick} from 'svelte';
import {route} from "@/utils";
Expand Down Expand Up @@ -60,18 +60,18 @@
{/if}
</div>

<JetValidationErrors hasErrors={$form.hasErrors} class="mb-4"/>

<form on:submit|preventDefault={submit}>
{#if !recovery}
<JetLabel id="code" label="Code"/>
<JetInput bind:this={codeInput} id="code" type="text" inputmode="numeric" class="mt-1 block w-full"
bind:value={$form.code} autofocus autocomplete="one-time-code"/>
<JetInputError message={$form.errors.code}/>

{:else}
<JetLabel id="recovery_code" label="Recovery Code"/>
<JetInput bind:this={recoveryCodeInput} id="recovery_code" type="text" class="mt-1 block w-full"
bind:value={$form.recovery_code} autocomplete="one-time-code"/>
<JetInputError message={$form.errors.code}/>
{/if}

<div class="flex items-center justify-end mt-4">
Expand Down

0 comments on commit 0c78ec8

Please sign in to comment.