-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth.isAuthenticated() — service._currentUser is null #25
Comments
Fix issue cloudspace#25 — Auth.isAuthenticated() — service._currentUser is null
|
So the issue is that a logged in user is being authenticated as false with the isAuthenticated() method. Upon investigation, this was because on login, the current user is not being set in the service.login() method. We are logging in the user as such: 1.) Inject devise.js into controller as $scope.login = function() {
console.log("Credentials: ", $scope.credentials);
Auth.login($scope.credentials).then(function(user) {
$scope.invalidLogin = false;
$scope.multipleLoginAttempts = false;
}, function(response) {
$scope.invalidLogin = true;
$scope.loginAttemptNumber += 1;
if ($scope.loginAttemptNumber >= 3) {
$scope.multipleLoginAttempts = true;
}
});
};
The issue I'm having is that this check returns |
The pull requests which I sent (which I am sorry for submitting from the |
The spot you've made the change is directly after the promise chain saves the parsed user. return $http(httpConfig('login', creds))
.then(service.parse)
.then(save)
.then(function(user) {
save(user); // Unnecessary
// Broadcast stuff
} I'm certain the user is being saved as is. I believe there is another issue, either do to async or due to the way you're testing the issue. If you (after undoing your changes) add the following then callback, does it output your user? Auth.login(creds).then(function(user) {
console.log(user);
console.log(Auth.isAuthenticated());
}); This should return your user object, and |
I have a similar problem. My app needs to be refreshed after log in so server can populate layout with some data related to user. Your example on previous comment work. But it doesn't after page refresh. While This is what happens after refresh: Auth.currentUser().then(function(user){
console.log(user)
// => Object { id: 28, first_name: null, last_name: null, customer_id: 1, status: "active",...}
})
console.log(Auth.isAuthenticated())
// => false
console.log(Auth)
// => Object { _currentUser: null, parse: AuthProvider/_parse(), login: AuthProvider/this.$get</service.login(),...} |
I was wrong actually. |
👍 |
Hey guys,
So we are using angular_devise with our application and are trying to utilize the service.isAuthenticated function in devise.js beginning on line 183. The problem is that service._currentUser is null.
In an attempt to debug this on our end, I found that save which is supposed to be called on login line 158 in the then. The problem is that save expects the user argument. If I add save(user) in next .then block, isAuthenticated works.
E.g. Doesn't work:
Works:
Is there something we are doing wrong or is this an issue with angular_devise?
The text was updated successfully, but these errors were encountered: