5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Chrome のパスワードマネージャの username は、 <input type="password"> の 直前に入力された値が設定される

Last updated at Posted at 2018-12-06

注: この記事に解決方法はありません

現象

システム上のユーザ名(emailとする)とパスワードの間に別の入力項目がある場合

<form action="/sign_up">
  <input type="text" name="email" autocomplete="username">
  <input type="text" name="nickname">
  <input type="password" name="password" autocomplete="new-password">
  <button type="submit">sign up</button>
</form>

メアドのみ先に送るようなユーザ登録フローでありがちな、 emailreadonly だったりする場合

<form action="/sign_up">
  <input type="text" name="nickname">
  <input type="text" name="email" autocomplete="username" readonly>
  <input type="password" name="password" autocomplete="new-password">
  <button type="submit">sign up</button>
</form>

以上のようなフォームを送信した時、 Google Chrome 71 のパスワードマネージャは nickname を ID として保存する。どうやら type=password の直前の入力をユーザ名として認識する様子。 autocomplete="username" なんのためにあるんだろう…

Google chrome autofilling all password inputs - Stack Overflow

Chrome auto fills any input with a type of password and then whatever the input before it is

Stack Overflow に同じ悩みの人を発見。 blurfocus を使って無理矢理 autocomplete 自体を動かないようにしてる

Password Form Styles that Chromium Understands - The Chromium Projects

If you've implemented an "email first" sign-in flow that separates the username and password into two separate forms, include a form field containing the username in the form used to collect the password. You can, of course, hide this field via CSS if that's appropriate for your layout.

Chromium の推奨(?)のサインアップフォームの作り方には、 隠しフィールドとして autocomplete="username" を追加せよと書かれているが、この通りにしても上記のようなフォームの username は認識されない。

その他の参考文献

進捗があったら追記する

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?