Angular JS/Django REST 更改密码模块问题。浏览器干扰我的代码
Angular JS/Django REST Change Password module issue. Browser interfering with my code
我是 angularJS 的新手。
我正在使用 Django REST 框架作为我的后端 API 并且我正在尝试实现用户的更改密码。
我有一个包含 2 个输入 [密码] 字段的表单,一个用于当前密码,另一个用于新密码,还有一个按钮。
现在,只要我单击“提交”,浏览器就会弹出一个 window 询问我 "Change password for which user." 并且列表是用我在浏览器中保存的用户及其密码制作的。
只有当我给输入字段类型 = "password" 而不是当我给它一个类型 = "text".
时才会发生这种情况
有人可以帮忙吗?
这是我的 HTML 视图。
<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>
这是我的 JS(控制器)
$scope.changePass = function(user){
AuthService.changePassword(user);
}
这是我的 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");
});
}
此致
许多浏览器可以自动检测 "standard login / password" 表单。当他们检测到此表单上的提交时,他们会显示此类对话框。
Angular 和 Django 真的不能为你做任何事情。您会在此处找到回复:Disable browser 'Save Password' functionality
我是 angularJS 的新手。 我正在使用 Django REST 框架作为我的后端 API 并且我正在尝试实现用户的更改密码。
我有一个包含 2 个输入 [密码] 字段的表单,一个用于当前密码,另一个用于新密码,还有一个按钮。
现在,只要我单击“提交”,浏览器就会弹出一个 window 询问我 "Change password for which user." 并且列表是用我在浏览器中保存的用户及其密码制作的。
只有当我给输入字段类型 = "password" 而不是当我给它一个类型 = "text".
时才会发生这种情况有人可以帮忙吗?
这是我的 HTML 视图。
<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>
这是我的 JS(控制器)
$scope.changePass = function(user){
AuthService.changePassword(user);
}
这是我的 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");
});
}
此致
许多浏览器可以自动检测 "standard login / password" 表单。当他们检测到此表单上的提交时,他们会显示此类对话框。
Angular 和 Django 真的不能为你做任何事情。您会在此处找到回复:Disable browser 'Save Password' functionality