2

I have coded a log in page and followed the advice on https://developers.google.com/web/fundamentals/design-and-ux/input/forms/ but Chrome still won't ask me to save my login. Any ideas what I'm missing?

    <form method="post" action="/admin/do.php?func=login">
    <div class="row justify-content-center">
    <div class="col-12 col-sm-6 col-md-4 col-lg-3 mb-3">
    <input tabindex="<?php echo $tabindex++; ?>" type="email" class="form-control" id="email" name="username" autocomplete="username" placeholder="Email address" value="">
    </div>
    <div class="col-12 col-sm-6 col-md-4 col-lg-3 mb-3">
    <input tabindex="<?php echo $tabindex++; ?>" type="password" class="form-control" id="password" name="current-password" autocomplete="current-password" placeholder="Password" value="">
    </div>
    <div class="col-4 col-md-3 col-lg-2 mb-3">
    <button tabindex="<?php echo $tabindex++; ?>" class="btn btn-primary btn-block" type="submit">Log in <i class="fas fa-arrow-right"></i></button>
    </div>
    </div>
    </form>
  • Without seeing your code, we have no ideas what you are missing. – catcon Aug 19 '19 at 04:09
  • Welcome to Stack Overflow! Links can go stale but hopefully this question and the answer will help others in the future so it is always helpful to have the relevant code in the question. It also makes it easier for others to help you. Check out [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) for more advice on how to improve the question and increase the likelihood that someone can help you. – Jaquez Aug 19 '19 at 04:25
  • Somehow chrome thinks every password is not correct, can you include the PHP code after a successful login ? do you response with `200 OK` or redirect to other page ? – Accountant م Aug 19 '19 at 06:15
  • Does Chrome not prompt for saving password, even with successful login ? – Accountant م Aug 19 '19 at 07:33

5 Answers5

1

Enable the "Offer to save passwords" setting at this link.
After the first login and save, the next logins are suggested.

also You should refer to chrome://settings/payments for the payments field. Then add. For address fields to chrome://settings/addresses

user206
  • 1,085
  • 1
  • 10
  • 15
  • My settings are correct and I still not getting the prompt on his website, he has another reason, that I can't figure out yet. – Accountant م Aug 19 '19 at 05:51
  • *"Also Remove console errors JS"* .... I didn't get that, do you mean not to log anything in the console ? – Accountant م Aug 19 '19 at 06:06
  • Yes I see those errors, but they are just normal 404 CSS files, I don't think they have nothing to do with the problem. – Accountant م Aug 19 '19 at 06:19
  • Temporarily change to type: type = "username". Form no problem. I tested in a script. And the offer to save ... – user206 Aug 19 '19 at 06:36
  • I removed the inline script at the end of the page and it still not working. type "username" is not a valid value for the `type` attribute of an `` element, please repeat the steps you did to make it work ! – Accountant م Aug 19 '19 at 06:42
  • I see you didn't change any of the `type` or `name` or `autocomplete` attributes ? right ? you just logged in successfully, that is all, right ? – Accountant م Aug 19 '19 at 07:20
  • And how did you logged in successfully, did the OP give you the admin password on his site ? – Accountant م Aug 19 '19 at 07:23
  • This is a local script (with the same form, etc.). See the second image (previous comment) – user206 Aug 19 '19 at 07:26
  • Man I really need to understand what exactly did you do to make this work ? I see in the images you posted, his page is the same, you didn't change anything, **what did you change on the page HTML to make it work** ? also how did you successfully logged in ? – Accountant م Aug 19 '19 at 07:35
  • Codes are exactly a copy of the page you have mentioned.. On the form `actionPage`, I have just returned. That's why I say: The form is okay.. – user206 Aug 19 '19 at 07:47
  • Aha, I got it, you changed the `action` attribute of the `
    `
    – Accountant م Aug 19 '19 at 07:58
  • Hello. I hope the problems are resolved. If you want to delete the comment (image link). tell me. – user206 Aug 20 '19 at 14:49
  • Hello My friend, yes your comments helped me :) ok delete the image links if you don't want them. – Accountant م Aug 20 '19 at 19:35
1

Thanks for your help, everyone. It turns out this problem was localised to a device, so my code is fine!

Still not sure why this one particular device hasn't synced the login details, but they are definitely syncing to others now so I will troubleshoot the one device separately.

1

Old question, but still a relevant topic.

The issue was only solved for me as soon as NET_CERT_AUTHORITY_INVALID flag was cleared from the browser.

To do this it required a trusted Cert Auth issued certificate. As soon as I installed my cert, passwords immediately became available for saving / auto-filling.

With self-signed SSL certs it wasn't possible to save / auto-fill passwords.

zenzone
  • 85
  • 6
0

Your email field has its autocomplete set to username.

Since your input accepts emails only, this creates confusion

You should set the autocomplete to email

Ferrybig
  • 18,194
  • 6
  • 57
  • 79
0

OK after 4 hours of investigating and testing login forms with Chrome here are my conclusion.

1- First, make sure your configurations are correct, I'm pretty sure your "Offer to save your web passwords" button is turned-on and everything is fine.

2- Chrome will not offer to save your password if it is not correct.

And how does he know if the password you just entered is correct or not ?

First I thought it will use the HTTP response status code for that, but it turns out it uses something else. I think after many tests that Chrome will think the password you just entered is wrong if he detected the same login form again on the response for submitting the form.

Suppose this is your login form :

<form method="post" action="/signin">
    <input  type="email" name="email" required>
    <input type="password" name="password" required>
</form>

On your server you are doing something like this

<?php
$loginForm = 
    '<form method="post" action="/signin">' . 
    '<input  type="email" name="email" required>' . 
    '<input type="password" name="password" required>' .
    '</form>';

if ($passwordIsCorrect){
    echo " You are logged in successfully!<br>";
    echo $loginForm;

} else {
    echo " Wrong email or password!<br>";
    echo $loginForm;
}

Chrome will think you entered wrong password even if you entered the correct one because he detects the same form with same input names. And this is why @user206 workaround of changing the action attribute of the form did work with him, because Chrome thought the password was correct because the same login form is not detected on the new action page.

3- Chrome will stop offering you to save password if you ignored the offer for the same username/email 3 times (you will need to use another name/email to invoke the offer again).

So to sum this up:

1- make sure your configurations are correct.

2- make sure the the page that you send after a successful login does not have the same login form.

3- make sure you didn't ignore the offer 3 times (you can try a different new email to make sure it's not this reason).

I did my tests on Chrome 76 on Linux

Community
  • 1
  • 1
Accountant م
  • 6,975
  • 3
  • 41
  • 61