public async Task <APIResult <LoginResponse> > Register(RegisterRequest request) { var c = HttpContext.Current; var v = request.isValid(); if (v.data == false) { return(APIResult <LoginResponse> .Error(v.code, v.message)); } string trueMobile = ""; if (General.ValidateMobile(request.phoneNumber, out trueMobile)) { request.phoneNumber = trueMobile; } else { return(APIResult <LoginResponse> .Error(ResponseCode.UserValidationField, "Invalid mobile number!")); } var verified = Users.MobileVerified(request.phoneNumber, request.verification_id); if (!verified.data) { return(APIResult <LoginResponse> .Error(ResponseCode.UserUnVerified, "Your phone still not verified!")); } #region Get User Data From Firebase try { if (FirebaseApp.DefaultInstance != null) { FirebaseApp.DefaultInstance.Delete(); } //{ FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(c.Server.MapPath("~/App_Data/firebase-config.json")), } ); } catch (Exception ex) { throw new Exception(ErrorHandler.Message(ex)); } FirebaseToken decodedToken; try { decodedToken = await FirebaseAuth.DefaultInstance.VerifyIdTokenAsync(request.access_token); } catch (Exception ex) { throw new Exception(ErrorHandler.Message(ex)); } string uid = decodedToken.Uid; string email = ""; string phone = request.phoneNumber; try { if (decodedToken.Claims.Keys.Contains("email")) { email = decodedToken.Claims.FirstOrDefault(a => a.Key == "email").Value.ToString(); } } catch (Exception ex) { throw new Exception(ErrorHandler.Message(ex)); } #endregion var f_name = request.first_name; var l_name = request.last_name; if (email == "") { return(APIResult <LoginResponse> .Error(ResponseCode.UserValidationField, "Email is required!")); } if (phone == "") { return(APIResult <LoginResponse> .Error(ResponseCode.UserValidationField, "Phone is required!")); } tbl_accounts acc = new tbl_accounts(); acc.city_id = request.city == 0?null:request.city; acc.country_id = request.country; acc.date_of_birth = request.date_of_birth; acc.email = email; acc.first_name = request.first_name; acc.gender_id = request.gender_id; acc.last_name = request.last_name; acc.mobile = phone; acc.register_time = DateTime.Now; return(Users.Register(acc, request.password, uid, c.Request.ServerVariables)); }