Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.inviteUser = functions
  2.     .region('europe-west1')
  3.     .https.onCall(async (data, context) => {
  4.         let company = await getCompanyNameFromUserId( context.auth.uid )
  5.         const { fullname, email, userId, password } = data;
  6.         let user = await Auth.createUser( {
  7.             email: email,
  8.             password: 'ARi5phie'+Math.random()
  9.         }
  10.         );
  11.  
  12.         console.log(company + " this is company");
  13.         const userData = {
  14.             userId: 'userId-' + user.uid,
  15.             fullname,
  16.             email,
  17.             password,
  18.             company,
  19.             role: 'user',
  20.             roleIn: 'invited',
  21.             logo: '',
  22.             dateAcceptedTOC: Date.now(),
  23.         };
  24.  
  25.         await companyApi.addUserToCompany(company, email, user.uid, 'invited', fullname, firestore);
  26.         return userApi.createAccount(userData, firestore);
  27.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement