Last active
August 17, 2016 13:33
-
-
Save dabit3/08473fe0014cfee89caad8ca1eef3bda to your computer and use it in GitHub Desktop.
Ionic cordova app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.doLogin = function(user) { | |
var deferred = $q.defer(), | |
nonce_dfd = $q.defer(), | |
authService = this; | |
authService.requestNonce("user", "generate_auth_cookie") | |
.then(function(nonce){ | |
nonce_dfd.resolve(nonce); | |
}); | |
nonce_dfd.promise.then(function(nonce){ | |
//now that we have the nonce, ask for the new cookie | |
authService.generateAuthCookie(user.userName, user.password, nonce) | |
.then(function(data){ | |
if(data.status == "error"){ | |
// return error message | |
deferred.reject(data.error); | |
}else{ | |
//recieve and store the user's cookie in the local storage | |
var user = { | |
cookie: data.cookie, | |
data: data.user, | |
user_id: data.user.id | |
}; | |
PushNotificationsService.register(); | |
authService.saveUser(user); | |
//getavatar in full size | |
authService.updateUserAvatar().then(function(){ | |
deferred.resolve(user); | |
}); | |
} | |
}); | |
}); | |
return deferred.promise; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes. Tried that. It triggers the registration function (console logs "cordovaPushv5 initialized"). Reaches the $cordovaPushV5.initialize and fails because it can't find variable PushNotification. When that code within the PushNotificationsService is loaded on device.ready in app.js, it does not have this problem.