//This method help to store the data in the Firebase and generates the Otp for the user for the user verification public async void registerNewUser(UserRegister user) { try { //connection to the Database Boolean connectionResult = connectToFirebase(); //creating secret key of the user string key = new string((user.Email_Address + user.Password).ToCharArray().OrderBy(x => Guid.NewGuid()).ToArray()); //inserting secret key to database //Create the Instance for the Document reference DocumentReference doc2 = db.Collection("UserKeys").Document(user.Email_Address); Dictionary <string, object> data2 = new Dictionary <string, object>() { { "email", user.Email_Address }, { "userKey", key }, }; await doc2.SetAsync(data2); //send the OTP to the User await sendOTP(user.Email_Address, user.First_Name + " " + user.Last_Name, false); user_Email = user.Email_Address; user_Password = user.Password; //Hash the password string[] hash_password = Password.giveHashPassword(user.Password); //Creating the User Instance for the persistance of the user data in the database //user is the object which contains the information retrieved by the user windows application DocumentReference doc1 = db.Collection("User").Document(user.Email_Address); //Create the Dictonary to Intialiaze the Object to be stored on the firestore //get the secure access Pin for the user PIN = GenerateRandomInt(000001, 999999); string bcrypt_PIN = Password.Bcrpyt_Password(PIN.ToString()); Dictionary <string, object> data1 = new Dictionary <string, object>() { { "email", user.Email_Address }, { "firstName", user.First_Name }, { "lastName", user.Last_Name }, { "dateOfBirth", user.Date_Of_Birth }, { "password", hash_password[1] }, { "questionSelected", user.Question_Number_Selected }, { "questionAnswered", user.Question_Answered }, { "salt", hash_password[0] }, { "verified", false }, { "accessPIN", bcrypt_PIN }, { "dateOfRegistration", System.DateTime.Now.ToString() }, }; //Set the account asynchronously on firestore database await doc1.SetAsync(data1); } catch (Exception ex) { //catch the exception and throw to the client side CustomException customException = new CustomException(); customException.errorTitleName = ex.Message; customException.errorMessageToUser = "******" + "Please Try Again Later!!"; throw new FaultException <CustomException>(customException); } }