Advertisement
Guest User

Untitled

a guest
Apr 19th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.37 KB | None | 0 0
  1. public async Task<ActionResult> Confirm(ConfirmAccountModel cam)
  2.         {
  3.             ViewBag.autoLogin = cam.autoLogin;
  4.  
  5.             var api = new IrisIdentityApi();
  6.             var uo = new UserOperations(api);
  7.             var request = new ConfirmPasswordResetRequest();
  8.  
  9.             var confirmPassed = true;
  10.  
  11.             var customizedConfig = ConfigurationHelper.CustomizedConfigs(Request.Url, cam.CustomCssFolder);
  12.  
  13.             if (customizedConfig != null)
  14.             {
  15.  
  16.                 ViewBag.CustomCssFolder = customizedConfig.AccountName;
  17.                 ViewBag.CompanyName = customizedConfig.CompanyName;
  18.                 ViewBag.DesktopCssFile = customizedConfig.DesktopCssFile;
  19.                 ViewBag.MobileCssFile = customizedConfig.MobileCssFile;
  20.                 ViewBag.PartnerName = customizedConfig.Container;
  21.                 ViewBag.ImageUrl = customizedConfig.LogoUrl;
  22.                 ViewBag.GeneratedDesktopCssUrl = customizedConfig.GeneratedDesktopCssUrl;
  23.                 ViewBag.GeneratedMobileCssUrl = customizedConfig.GeneratedMobileCssUrl;
  24.                 ViewBag.CompanyWebAddress = customizedConfig.WebAddress;
  25.             }
  26.  
  27.             DFPerson dfp = null;
  28.  
  29.             if (!ModelState.IsValid) //If validation fails, we display the confirmation page again
  30.             {
  31.                 dfp = DeepfieldDataPerson.ConfirmationCode(cam.Code);
  32.  
  33.                 ViewBag.Confirmed = false;
  34.                 if (dfp.Id != 0)
  35.                 {
  36.                     ViewBag.Confirmed = true;
  37.                     cam.Username = dfp.Username;
  38.                     cam.Firstname = dfp.Firstname;
  39.                     cam.Surname = dfp.Lastname;
  40.                     cam.Type = dfp.Data2;
  41.                 }
  42.                 return View(cam);
  43.             }
  44.  
  45.             //If validation passed we carry on to try and confirm
  46.             ViewBag.Confirmed = false;
  47.  
  48.             dfp = DeepfieldDataPerson.ConfirmationCode(cam.Code);
  49.  
  50.             // Set confirm password reset request properties
  51.             request.ConfirmationCode = cam.Code;
  52.             request.Email = dfp.Email;
  53.             request.NewPassword = cam.NewPassword;
  54.  
  55.             if (dfp.Id != 0)
  56.             {
  57.                 // Check if the Identity system is switched on
  58.                 if (DeepfieldUtility.IsFeatureAvailable("Identity"))
  59.                 {
  60.                     // Confirm reset password on Identity system
  61.                     try
  62.                     {
  63.                         await uo.ConfirmPasswordResetAsyncAsync(request);
  64.                     }
  65.                     catch (HttpOperationException ex)
  66.                     {
  67.                         LOGGER.Error("Confirm account registration on Identity system: " + ex.Response.ReasonPhrase);
  68.                         TempData["ErrorState"] = "Confirm account registration on Identity system: " + ex.Response.ReasonPhrase;
  69.                         confirmPassed = false;
  70.                     }
  71.                 }
  72.  
  73.                 // If confirm password reset on Identity system succeeded
  74.                 if (confirmPassed)
  75.                 {
  76.                     // Confirm account registration on OpenSpace
  77.                     ViewBag.Confirmed = DeepfieldDataPerson.ConfirmAccountRegistration(cam);
  78.                 }
  79.             }
  80.             return View(ViewBag.Confirmed ? "ConfirmSuccess" : "ConfirmFail", cam);
  81.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement