Пример #1
0
        public ActionResult Forgot(PasswordClaim password)
        {
            if (ModelState.IsValid)
            {
                var claimResponse = new PlatformManagementService.DataAccessResponseType();
                var platformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient();

                try
                {
                    //Attempt to send lost password claim
                    platformManagementServiceClient.Open();
                    claimResponse = platformManagementServiceClient.ClaimLostPassword(password.Email, Common.SharedClientKey);

                    //Close the connection
                    WCFManager.CloseConnection(platformManagementServiceClient);
                }
                catch (Exception e)
                {
                    #region Manage Exception

                    string exceptionMessage = e.Message.ToString();

                    var    currentMethod       = System.Reflection.MethodBase.GetCurrentMethod();
                    string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name;

                    // Abort the connection & manage the exception
                    WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString);

                    // Upate the response object
                    claimResponse.isSuccess    = false;
                    claimResponse.ErrorMessage = WCFManager.UserFriendlyExceptionMessage;
                    //claimresponse.ErrorMessages[0] = exceptionMessage;

                    #endregion
                }


                if (claimResponse.isSuccess)
                {
                    return(RedirectToAction("sent", "password"));
                }
                else
                {
                    //ModelState.AddModelError("", "Invalid username or password.");

                    //foreach (string error in authResponse.ErrorMessages)
                    //{
                    ModelState.AddModelError("CoreServiceError", claimResponse.ErrorMessage);
                    //}

                    return(View(password));
                }
            }
            else
            {
                return(View(password));
            }
        }