I'm new to angularJS. I am using Django REST framework as my backend API and im trying to implement change password of a user.
I have a form that contains 2 input[password] fields, one for current password and other for new, and a button.
Now as soon as i click submit the browsers pops up a window that asks me "Change password for which user." and the list is made with the saved users and their passwords i have in my browser.
This is happening only when i an giving input field type = "password" and not when im giving it a type = "text".
Can someone help?
This is my HTML View.
<form name="change_pass" ng-submit="changePass(user)">
<md-input-container class="md-accent md-hue-2">
<md-icon class="material-icon">lock</md-icon>
<input ng-model="user.currentPass" type="password" placeholder="Current Password" >
</md-input-container>
<md-input-container class="md-accent md-hue-2">
<md-icon class="material-icon">lock</md-icon>
<input ng-model="user.newPass" type="password" placeholder="New Password" >
</md-input-container>
<md-button type="submit" class="md-raised md-primary">Submit</md-button>
</form>
This is my JS(Controller)
$scope.changePass = function(user){
AuthService.changePassword(user);
}
This is my AuthService
Authorization.changePassword = function(user){
var id = $cookies.get('user');
var postData = {
"newpassword": user.newPass,
"username": id,
"currentpassword": user.currentPass
}
$activityIndicator.startAnimating();
$http({
method: 'PUT',
url: CHANGE_PASSWORD+id+'/',
data: postData,
headers: {'Authorization': 'Token ' + $cookies.get('token')}
})
.success(function(data, status, header, config){
$activityIndicator.stopAnimating();
toastr.success("Password Sucessfully changed!", " Security");
})
.error(function(data, status, header, config){
$activityIndicator.stopAnimating();
toastr.error("Your Password could not be changed", " Security");
});
}
Regards