I am trying to implement a custom API authentication method as suggested below.
Password protecting a REST service?
However, I am having some trouble with the authkey. I would like to save my authkey received as a global variable but I can't seem to change it, it always become the same value as what it is defined to be at the start.
I am implement global variable using angular (v0.9) service.
snippet of my code
angular.service('Authkey', function(){
return {
"authkey": "0000"
};
});
controller
function LoginCtrl(Login_, Authkey_){
this.login = function(){
Login_.query({"Username": this.email,"Password": this.password}, function(response){
if (response.success === "true") {
Authkey_.authkey = response.AuthKey;
console.log(Authkey_.authkey);
window.location="/main.html";
}
});
}
}
Yup. It always become 0000 after the page is changed.
Appreciate all help I can get. Thank you..