public ActionResult ActualResetPassword(DataModel model)
        {
            using (var e = new EntityContext())
            {
                var data = ActionData.GetAction <DataModel>(Guid.Parse(model.Guid), e);
                model.Email = data.Item1.Email;
                var actionRow = data.Item2;
                if (model == null || actionRow == null || actionRow.Investigator_Name == null)
                {
                    return(View(ResetPasswordErrorView));
                }

                // clears the errors from the model
                model.ClearToaster();
                // check for simple warnings
                var isValid = true;
                // makes sure we don't have any empty fields
                if (String.IsNullOrEmpty(model.Password) || String.IsNullOrEmpty(model.Email))
                {
                    model.AddError(GlobalErrors.EmptyFields);
                    isValid = false;
                }
                if (!CredentialsHelper.IsPasswordValid(model.Password)) // check password is valid
                {
                    model.AddError(RegistrationErrors.InvalidPassword);
                    isValid = false;
                }
                else // if password is valid get warnings
                {
                    model.AddWarnings(CredentialsHelper.GetPasswordWarnings(model.Password));
                }


                if (isValid)                                 // check for more serious warnings
                {
                    using (var e2 = new EntityContext())     // db context
                    {
                        if (isValid && !model.HasWarnings()) // we have checked everything we need to check
                        {
                            var success = Authorize.ResetPassword(model.Email, model.Password, e2);

                            e.Web_Action_Data.Remove(actionRow);
                            e.SaveChanges();
                            if (!success)
                            {
                                return(View(ResetPasswordErrorView));
                            }
                            else
                            {
                                return(View(ResetPasswordSuccessView));
                            }
                        }
                    }
                }
            }
            // if we got here there was an error
            return(View(ReceivedView, model));
        }
예제 #2
0
    private void SelectTarget(ActionData actionData)
    {
        targetMenu.Populate(
            actionData,
            Actor,
            factionMap,
            target => selectedAction = actionData.GetAction(Actor, target));

        stateMachine.SetState(targetMenuState);
    }
 // standardized what happens on confirm action
 public ActionResult Received(String actionGuid)
 {
     using (var e = new EntityContext())
     {
         var data      = ActionData.GetAction <DataModel>(Guid.Parse(actionGuid), e);
         var model     = data.Item1;
         var actionRow = data.Item2;
         if (model == null || actionRow == null || actionRow.Investigator_Name == null)
         {
             return(View(ResetPasswordErrorView));
         }
         model.Guid = actionGuid;
         //e.Web_Action_Data.Remove(actionRow);
         //e.SaveChanges();
         return(View(ReceivedView, model));
     }
 }
예제 #4
0
        // standardized what happens on confirm action
        public ActionResult Received(String actionGuid)
        {
            using (var e = new EntityContext())
            {
                var data      = ActionData.GetAction <DataModel>(Guid.Parse(actionGuid), e);
                var model     = data.Item1;
                var actionRow = data.Item2;
                if (model == null || actionRow == null || actionRow.Investigator_Name == null)
                {
                    return(View(ConfirmationErrorView));
                }
                var success = Authorize.ConfirmEmail(model.Email, model.Username, actionRow.Investigator_Name, e);
                if (!success)
                {
                    return(View(ConfirmationErrorView));
                }
                e.Web_Action_Data.Remove(actionRow);
                e.SaveChanges();
            }

            return(View(ReceivedView));
        }