0
使用AngularJS和Spring Security,當身份驗證失敗時,重定向到登錄頁面error=true
。我需要在登錄頁面(AngularJS)上顯示此錯誤。我不知道該怎麼做。無法檢索關聯的錯誤並在登錄頁面中顯示
下面是authentication-failure-url
在ssecurity-context.xml
聲明:
<security:form-login login-page="/login"
login-processing-url="/authenticate"
authentication-failure-url="/login?error=true"
username-parameter="username" password-parameter="password"/>
一些能請告訴我如何檢索錯誤,並顯示登錄頁面上?
JS
angular.module('app.services')
.service('AuthenticateService',['$http','$location',function($http,$location)
{
return
{
login : function(uname, pword)
{
var data = "username="+uname+"&password="+pword;
return $http.post("authenticate",data,
{
headers: { "Content-Type": "application/x-www-form-urlencoded" } })
.then(function (response)
{
console.log(response.status);
},function(error)
{
console.log(error.status);
});
}
}
}]);