0

I have a login form that uses ng-model to pass the data to the controller. When the ng-submit is called, I pass this data to the server to authenticate the user.

However, in Firefox only, and only on our live (https) server, the model values are never updated. Using console.log($scope.loginform) simply prints the default values:

{ username="", password=""}

In development (http), and when using Chrome, it properly updates them with the entered values:

{ username="kermit", password="noteasybeinggreen"}

Here's my form, in jade format

form(method='post',ng-submit='login()')
    ol
        li
            label(class='icon-user')
            input(type='text',name='username',ng-model='loginform.username',placeholder='Username')
        li
            label(class='icon-key')
            input(type='password',name='password',ng-model='loginform.password',placeholder='Password',class='pass')
        li
            input(type='submit',class='pressable',value='Login')

And my controller:

.controller('LoginController', ['$scope','$http','$stateParams',function($scope,$http,$stateParams) {
    $scope.loginform = {
        username: '',
        password: ''
    };

    $scope.login = function() {
        console.log( 'login called: ', $scope.loginform );
        $http.post('/login', $scope.loginform).success(function(resp, status, headers, config) {
            // stuff
        })
        .error(function(resp, status, headers, config){
            // stuff
        });
    };
}]);

Is there something I'm missing, doing wrong, etc? I can't understand why it's only Firefox.

This page is currently live at https://pste.me/#/login

pseudonym117
  • 799
  • 1
  • 5
  • 22
helion3
  • 34,737
  • 15
  • 57
  • 100

1 Answers1

0

I found the cause.

It seems that when a browser auto-fills a username/password field, the ng-model doesn't update.

See AngularJS browser autofill workaround by using a directive for possible fixes.

Community
  • 1
  • 1
helion3
  • 34,737
  • 15
  • 57
  • 100