public async Task <IActionResult> Refresh([FromBody] RefreshTempUser model) { var existing = _context.Users.FirstOrDefault(user => user.PhoneNumber == model.PhoneNumber.CleanPhone()); if (existing == null) { return(ResponseShell.Error("Could not find user.", new List <string>() { "Either the GenericUser account has not been created", "Or service is temporarily unavailable" })); } if (Constants.Testing.CheckIfOverride(existing) && (_hostingEnvironment.IsDevelopment() || _hostingEnvironment.IsEnvironment("Testing"))) { existing.Token = Constants.Testing.TestValidationToken; // Hold our token and model for a while to give our user a chance to validate their info _memoryCache.SetForChallenge(new TempUser(existing)); // All good thus far, now we just wait on our user to validate return(ResponseShell.Ok(new SimpleSuccess() { Success = true })); } // Fire off our validation var token = await _smsSender.SendValidationToSms(new TempUser() { Email = existing.Email, Id = existing.Id, }); existing.Token = token; // Hold our token and model for a while to give our user a chance to validate their info _memoryCache.SetForChallenge(new TempUser(existing)); // All good thus far, now we just wait on our user to validate return(ResponseShell.Ok(new SimpleSuccess())); }