I have a factory called Auth with a method Auth.signIn()
that authenticates through my decoupled API. That part works, and I'm trying to capture the response which is the User information. Calling the factory from my controller works, but I can't seem to capture the response of the method.
controller
.controller('DashCtrl', function($scope, Auth) {
//OAUTH SIGN IN
$scope.signIn = function() {
$scope.currentUser = Auth.signIn()
//^^Auth.signIn() is happening but $scope.currentUser is undefined when I try to access it in the view
}
//OAUTH SIGN OUT
$scope.signOut = function() {
Auth.signOut()
}
})
factory
.factory('Auth', function($auth) {
var user = null
return {
signIn: function() {
$auth.authenticate('google')
.then(function(response) {
return response //trying to catch this in the controller with currentUser = Auth.signIn()
//verified that response is the user data
})
.catch(function(resp) {
// handle errors
})
}
})
I'm new to angular so any help and pointers would be appreciated. I'm trying to be as concise as possible with my code/questions. Thank you in advance for helping.