AngularJSとSpring Securityを使用すると、認証が失敗したときにログインページにerror=true
でリダイレクトされます。ログインページ(AngularJS)にこのエラーを表示する必要があります。私はこれをする方法を知らない。関連付けられたエラーを取得してログインページに表示することができません
はssecurity-context.xml
でauthentication-failure-url
の宣言です:
<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);
});
}
}
}]);