in src/Web/Controllers/ManageController.cs [92:180]
public async Task<IActionResult> Index(IndexViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
// Update the Application User
user.FirstName = model.User.FirstName;
user.LastName = model.User.LastName;
user.Email = model.User.Email;
user.UserName = model.Username;
user.PhoneNumber = model.User.Phone;
user.Address1 = model.Address.Address1;
user.Address2 = model.Address.Address2;
user.City = model.Address.City;
user.State = model.Address.State;
user.ZipCode = model.Address.ZipCode;
user.CountryRegion = model.Address.CountryRegion;
var result = await _userManager.UpdateAsync(user);
#region Fraud Protection Service
// If storing the user locally succeeds, update Fraud Protection
if (result.Succeeded)
{
var billingAddress = new UserAddress
{
Type = UserAddressType.Billing.ToString(),
FirstName = user.FirstName,
LastName = user.LastName,
Street1 = user.Address1,
Street2 = user.Address2,
City = user.City,
State = user.State,
ZipCode = user.ZipCode,
Country = user.CountryRegion
};
var shippingAddress = new UserAddress
{
Type = UserAddressType.Shipping.ToString(),
FirstName = user.FirstName,
LastName = user.LastName,
Street1 = user.Address1,
Street2 = user.Address2,
City = user.City,
State = user.State,
ZipCode = user.ZipCode,
Country = user.CountryRegion
};
var fraudProtectionUser = new User
{
UserId = user.Email,
UpdateDate = DateTimeOffset.Now,
Email = user.Email,
FirstName = user.FirstName,
LastName = user.LastName,
PhoneNumber = user.PhoneNumber,
AddressList = new List<UserAddress> { billingAddress, shippingAddress },
ZipCode = user.ZipCode,
Country = user.CountryRegion,
TimeZone = new TimeSpan(0, 0, -model.DeviceFingerPrinting.ClientTimeZone, 0).ToString(),
DeviceContext = new DeviceContext
{
DeviceContextId = _contextAccessor.GetSessionId(),
IPAddress = _contextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(),
Provider = DeviceContextProvider.DFPFingerPrinting.ToString()
}
};
var correlationId = _fraudProtectionService.NewCorrelationId;
var response = await _fraudProtectionService.PostUser(fraudProtectionUser, correlationId);
var fraudProtectionIO = new FraudProtectionIOModel(correlationId, fraudProtectionUser, response, "UpdateAccount");
TempData.Put(FraudProtectionIOModel.TempDataKey, fraudProtectionIO);
}
#endregion
StatusMessage = "Your profile has been updated";
return RedirectToAction(nameof(Index));
}