【问题标题】:AngularJS + PassPort with autofill and remember passwordAngularJS + PassPort 自动填充和记住密码
【发布时间】:2014-10-21 01:46:44
【问题描述】:

我的网络应用上有一个登录页面,有 2 个输入(电子邮件/密码)。实际上一切都适用于 NodeJS / PassPort / Angular。但是,我在 Chrome 和 Firefox 上遇到了自动填充和记住密码的问题。

1) 在 Chrome 上,浏览器不会询问我是否要保存密码,没有自动填充功能,它不记得我的表单上的任何内容。这很烦人。

2) 在 Firefox 上,浏览器要求我保存密码并保存。但是,当我重新打开它时,我的输入已填满,但如果我单击“登录”,则没有任何反应,我必须在登录前编辑每个字段中的值。

我已经阅读了很多关于 AJAX 和自动填充的内容,但是我对这类内容完全陌生,我并不了解所有内容。

这是我的前端代码:

登录.html

<form class="form-signin"
                      name="form"
                      ng-submit="login(form)"
                      novalidate>

                    <div ng-class="{'has-error': form.email.$error.mongoose}">
                        <input type="text"
                               class="form-control"
                               placeholder="Email"
                               name="email"
                               ng-model="user.email"
                               required
                               autofocus
                               mongoose-error>
                        <p class="help-block"
                           ng-show="form.email.$error.mongoose">
                            {{ errors.email }}
                        </p>
                    </div>

                    <div ng-class="{'has-error': form.password.$error.mongoose}">
                        <input type="password"
                               class="form-control"
                               placeholder="Password"
                               name="password"
                               ng-model="user.password"
                               required
                               mongoose-error>
                        <p class="help-block"
                           ng-show="form.password.$error.mongoose">
                            {{ errors.password }}
                        </p>
                    </div>

                    <div class="form-group has-error">
                        <p class="help-block">{{ error.other }}</p>
                    </div>

                    <button class="btn btn-lg btn-danger btn-block" type="submit"> Sign in </button>

                    <span class="clearfix"></span>
                </form>

login.js(控制器)

$scope.login = function(form) {
      var str = $scope.user.email;
      Auth.login('password', {
          'email': str.toLowerCase(),
          'password': $scope.user.password
        },
        function(err) {
          $scope.errors = {};

          if (!err) {
            $location.path('/page/1');
          } else {
            angular.forEach(err.errors, function(error, field) {
              form[field].$setValidity('mongoose', false);
              $scope.errors[field] = error.type;
            });
            $scope.error.other = err.message;
          }
      });

感谢您的帮助。

【问题讨论】:

  • 请分享到jsfiddle

标签: angularjs autocomplete passwords autofill


【解决方案1】:
  1. 查看此讨论https://github.com/fnakstad/angular-client-side-auth/issues/58。一种 chrome 错误。

  2. 试试https://github.com/tbosch/autofill-event。适合我的项目。

【讨论】:

    猜你喜欢
    • 2013-09-06
    • 2019-09-02
    • 2023-01-10
    • 2016-08-15
    • 2021-07-02
    • 1970-01-01
    • 2014-12-07
    • 2015-11-19
    • 1970-01-01
    相关资源
    最近更新 更多