Hi guys,
I’m following this tutorial written by Mr Simon about create a login.
But I’m facing a problem when I want it to check the credentials stored in a database with php.
I modified the services.js to check, but I can figure out what is wrong!
Please I need your help, i’m stuck on this…
Here is the code I modified in service.js:
var login = function( name, pw) {
$rootScope.rsJSON = [ ];
//
var req = {
method: 'POST',
url: 'http://localhost/test/index.php',
headers: {
'Content-Type': undefined
},
data: { usuario : name , contrasena : pw },
dataType: "jsonp"
}
$http(req)
.success(function(data, $state) {
//
return $q(function(resolve, reject) {
if (typeof(data.USUARIO) == "undefined") {
// Make a request and receive your auth token from your server
reject('Login Failed.');
} else {
storeUserCredentials(name + '.yourServerToken');
resolve('Login success.');
}
});
})
.error(function(data) {
console.log('Error: ' + data);
});
};
I received the follow errors:
- Error: AuthService.login(…) is undefined;
- Error: Unexpected request: POST http://localhost/test/index.php