Skip to content

Commit

Permalink
Add autocomplete attrs to password/username fields (#5143)
Browse files Browse the repository at this point in the history
* Git ignore

* Add autocompletes

* Fix formatting

* Revert commit

---------

Co-authored-by: Steffen Deusch <[email protected]>
  • Loading branch information
janwillemvd and SteffenDE authored Nov 26, 2024
1 parent 086b837 commit c927ef0
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
</.header>
<.simple_form for={@form} id="resend_confirmation_form" phx-submit="send_instructions">
<.input field={@form[:email]} type="email" placeholder="Email" required />
<.input
field={@form[:email]}
type="email"
placeholder="Email"
autocomplete="username"
required
/>
<:actions>
<.button phx-disable-with="Sending..." class="w-full">
Resend confirmation instructions
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/phx.gen.auth/confirmation_new.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</.header>

<.simple_form :let={f} for={@conn.params["<%= schema.singular %>"]} as={:<%= schema.singular %>} action={~p"<%= schema.route_prefix %>/confirm"}>
<.input field={f[:email]} type="email" placeholder="Email" required />
<.input field={f[:email]} type="email" placeholder="Email" autocomplete="username" required />
<:actions>
<.button phx-disable-with="Sending..." class="w-full">
Resend confirmation instructions
Expand Down
8 changes: 7 additions & 1 deletion priv/templates/phx.gen.auth/forgot_password_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
</.header>
<.simple_form for={@form} id="reset_password_form" phx-submit="send_email">
<.input field={@form[:email]} type="email" placeholder="Email" required />
<.input
field={@form[:email]}
type="email"
placeholder="Email"
autocomplete="username"
required
/>
<:actions>
<.button phx-disable-with="Sending..." class="w-full">
Send password reset instructions
Expand Down
10 changes: 8 additions & 2 deletions priv/templates/phx.gen.auth/login_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
</.header>
<.simple_form for={@form} id="login_form" action={~p"<%= schema.route_prefix %>/log-in"} phx-update="ignore">
<.input field={@form[:email]} type="email" label="Email" required />
<.input field={@form[:password]} type="password" label="Password" required />
<.input field={@form[:email]} type="email" label="Email" autocomplete="username" required />
<.input
field={@form[:password]}
type="password"
label="Password"
autocomplete="current-password"
required
/>
<:actions>
<.input field={@form[:remember_me]} type="checkbox" label="Keep me logged in" />
Expand Down
10 changes: 8 additions & 2 deletions priv/templates/phx.gen.auth/registration_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
Oops, something went wrong! Please check the errors below.
</.error>
<.input field={@form[:email]} type="email" label="Email" required />
<.input field={@form[:password]} type="password" label="Password" required />
<.input field={@form[:email]} type="email" label="Email" autocomplete="username" required />
<.input
field={@form[:password]}
type="password"
label="Password"
autocomplete="new-password"
required
/>
<:actions>
<.button phx-disable-with="Creating account..." class="w-full">Create an account</.button>
Expand Down
10 changes: 8 additions & 2 deletions priv/templates/phx.gen.auth/registration_new.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
Oops, something went wrong! Please check the errors below.
</.error>

<.input field={f[:email]} type="email" label="Email" required />
<.input field={f[:password]} type="password" label="Password" required />
<.input field={f[:email]} type="email" label="Email" autocomplete="username" required />
<.input
field={f[:password]}
type="password"
label="Password"
autocomplete="new-password"
required
/>

<:actions>
<.button phx-disable-with="Creating account..." class="w-full">Create an account</.button>
Expand Down
9 changes: 8 additions & 1 deletion priv/templates/phx.gen.auth/reset_password_edit.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
Oops, something went wrong! Please check the errors below.
</.error>

<.input field={f[:password]} type="password" label="New Password" required />
<.input
field={f[:password]}
type="password"
label="New Password"
autocomplete="new-password"
required
/>
<.input
field={f[:password_confirmation]}
type="password"
label="Confirm new password"
autocomplete="new-password"
required
/>
<:actions>
Expand Down
9 changes: 8 additions & 1 deletion priv/templates/phx.gen.auth/reset_password_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
Oops, something went wrong! Please check the errors below.
</.error>
<.input field={@form[:password]} type="password" label="New password" required />
<.input
field={@form[:password]}
type="password"
label="New password"
autocomplete="new-password"
required
/>
<.input
field={@form[:password_confirmation]}
type="password"
label="Confirm new password"
autocomplete="new-password"
required
/>
<:actions>
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/phx.gen.auth/reset_password_new.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</.header>

<.simple_form :let={f} for={@conn.params["<%= schema.singular %>"]} as={:<%= schema.singular %>} action={~p"<%= schema.route_prefix %>/reset-password"}>
<.input field={f[:email]} type="email" placeholder="Email" required />
<.input field={f[:email]} type="email" placeholder="Email" autocomplete="username" required />
<:actions>
<.button phx-disable-with="Sending..." class="w-full">
Send password reset instructions
Expand Down
10 changes: 8 additions & 2 deletions priv/templates/phx.gen.auth/session_new.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
<.simple_form :let={f} for={@conn.params["<%= schema.singular %>"]} as={:<%= schema.singular %>} action={~p"<%= schema.route_prefix %>/log-in"}>
<.error :if={@error_message}><%%= @error_message %></.error>

<.input field={f[:email]} type="email" label="Email" required />
<.input field={f[:password]} type="password" label="Password" required />
<.input field={f[:email]} type="email" label="Email" autocomplete="username" required />
<.input
field={f[:password]}
type="password"
label="Password"
autocomplete="current-password"
required
/>

<:actions :let={f}>
<.input field={f[:remember_me]} type="checkbox" label="Keep me logged in" />
Expand Down
13 changes: 11 additions & 2 deletions priv/templates/phx.gen.auth/settings_edit.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

<input type="hidden" name="action" value="update_email" />

<.input field={f[:email]} type="email" label="Email" required />
<.input field={f[:email]} type="email" label="Email" autocomplete="username" required />
<.input
field={f[:current_password]}
name="current_password"
type="password"
label="Current Password"
autocomplete="current-password"
required
id="current_password_for_email"
/>
Expand All @@ -39,11 +40,18 @@

<input type="hidden" name="action" value="update_password" />

<.input field={f[:password]} type="password" label="New password" required />
<.input
field={f[:password]}
type="password"
label="New password"
autocomplete="new-password"
required
/>
<.input
field={f[:password_confirmation]}
type="password"
label="Confirm new password"
autocomplete="new-password"
required
/>

Expand All @@ -53,6 +61,7 @@
type="password"
label="Current password"
id="current_password_for_password"
autocomplete="current-password"
required
/>
<:actions>
Expand Down
20 changes: 18 additions & 2 deletions priv/templates/phx.gen.auth/settings_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
phx-submit="update_email"
phx-change="validate_email"
>
<.input field={@email_form[:email]} type="email" label="Email" required />
<.input
field={@email_form[:email]}
type="email"
label="Email"
autocomplete="username"
required
/>
<.input
field={@email_form[:current_password]}
name="current_password"
id="current_password_for_email"
type="password"
label="Current password"
value={@email_form_current_password}
autocomplete="current-password"
required
/>
<:actions>
Expand All @@ -47,13 +54,21 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
name={@password_form[:email].name}
type="hidden"
id="hidden_<%= schema.singular %>_email"
autocomplete="username"
value={@current_email}
/>
<.input field={@password_form[:password]} type="password" label="New password" required />
<.input
field={@password_form[:password]}
type="password"
label="New password"
autocomplete="new-password"
required
/>
<.input
field={@password_form[:password_confirmation]}
type="password"
label="Confirm new password"
autocomplete="new-password"
/>
<.input
field={@password_form[:current_password]}
Expand All @@ -62,6 +77,7 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
label="Current password"
id="current_password_for_password"
value={@current_password}
autocomplete="current-password"
required
/>
<:actions>
Expand Down

0 comments on commit c927ef0

Please sign in to comment.