当我尝试使用无效的用户名和密码登录时,它会显示消息为"无效的用户名或密码"。
但是如果它的用户名或密码无效,那么密码字段就会重置。
任何人都可以帮我怎么做?
我的控制器:
function login() {
vm.dataLoading = true;
var baseUrl = $location.$$absUrl.split('#')[0];
AuthenticationService.Login(vm.username, vm.password, baseUrl, function (response) {
console.log(response);
if( response.success !== undefined ){
FlashService.Error(response.message, true);
} else {
if (response.json.response.statuscode == 0) {
AuthenticationService.SetCredentials(vm.username, vm.password, response.json.response.candidateid, response.json.response.profilestatus);
//( response.json.response.profilestatus < 15 ) ? $location.path('/otp') : $location.path('/');
$location.path('/')
} else {
FlashService.Error(response.json.response.statusmessage);
vm.dataLoading = false;
}
}
});
};
我的HTML
<div class=" well tab-content">
<div role="tabpanel" class="tab-pane active" id="personal">
<div class="row">
<div class="col-sm-10 col-lg-offset-1">
<form name="form" ng-submit="vm.login()" role="form">
<div class="form-group" ng-class="{ 'has-error': form.username.$dirty && form.username.$invalid }">
<label for="username">Email</label>
<input type="email" placeholder="Email" name="username" id="username" class="form-control" ng-model="vm.username" required />
<span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">Email required</span>
<span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">Invalid Email Id</span>
</div>
<div class="form-group" ng-class="{ 'has-error': form.password.$dirty && form.password.$error.required }">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="Password" ng-model="vm.password" required />
<span ng-show="form.password.$dirty && form.password.$error.required" class="help-block">Password required</span>
</div>
<div class="form-actions">
<button type="submit" ng-disabled="form.$invalid || vm.dataLoading" class="btn btn-info">Login</button><a href="#/resetpassword" class="btn btn-link">Forgot Password?</a>
<img ng-if="vm.dataLoading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
<hr>
</div>
答案 0 :(得分:1)
您需要重置控制器中的vm.password,因为您的密码输入“ng-model”是vm.password
收到错误后,请尝试:
vm.password = "";
vm.password = undefined;
delete vm.password;