daily pastebin goal
68%
SHARE
TWEET

Untitled

luisruiz Oct 17th, 2018 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.addUser = functions.https.onCall((data, context) => {
  2.         const docId = data.uid;
  3.         // var userData = context.data.data();
  4.         const userData = data;
  5.         // Set user data to variables    
  6.         const email = userData.email;
  7.         const password = userData.password;
  8.  
  9.         // Create user with variable data
  10.         return admin.auth().createUser({
  11.                 uid: docId,
  12.                 email: email,
  13.                 password: password,
  14.              
  15.  
  16.             }).then((userRecord) => {
  17.                 console.log('se creo el usuario con exito');
  18.  
  19.                 return userRecord;
  20.             })
  21.             .catch((error) => {
  22.                 console.log("Error al crear nuevo usuario:", error);
  23.  
  24.                 return error;
  25.             });
  26.     })
  27.  
  28. exports.deleteUser = functions.https.onCall((data, context) => {
  29.     var user = data.userId;
  30.     var promiseAuth = admin.auth().deleteUser(user);
  31.     var promiseDoc = admin.firestore().collection('users').doc(user).delete();
  32.     return Promise.all([promiseAuth,promiseDoc]).then((res) => {
  33.         console.info('Usuario Eliminado: ' + res)
  34.         return { status : true, message: res}
  35.        
  36.     }).catch(err => {
  37.         console.log('usuario no eliminados: ' + err )
  38.         return {status : false, message: err}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top