Last active
August 29, 2015 14:07
-
-
Save abelorian/8fec3af07374867fe0be to your computer and use it in GitHub Desktop.
Parse Service for AngularJS
This file contains 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
'use strict' | |
angular.module('MODULENAME', []) | |
.service('ParseService', function() { | |
var appKey = 'YOUR appKey'; | |
var jsKey = 'YOUR jsKey'; | |
console.log('Servicio..'); | |
Parse.initialize(appKey, jsKey); | |
return { | |
getName: function() { | |
return Parse.User.current().get('name'); | |
}, | |
getEmail: function() { | |
return Parse.User.current().getEmail(); | |
}, | |
isLoggedIn: function() { | |
var currentUser = Parse.User.current(); | |
return (currentUser) ? true : false; | |
}, | |
resetPassword: function(email) { | |
Parse.User.requestPasswordReset(email, { | |
success: function() { | |
// Password reset request was sent successfully | |
}, | |
error: function(error) { | |
// Show the error message somewhere | |
alert("Error: " + error.code + " " + error.message); | |
} | |
}); | |
}, | |
logout: function(){ | |
Parse.User.logOut(); | |
console.log('Cerrando sesion...'); | |
return true; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment