Exemplo n.º 1
0
        public virtual ActionResult Register()
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            if (!currentMember.IsActive)
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "You must first active an account with us before you can register a Group",
                    Title = ErrorStrings.TITLE_WARNING,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Home.Index()),
                };

                returnValue = View("Message", messageModel);
            }
            else
            {
                returnValue = View();
            }

            return returnValue;
        }
Exemplo n.º 2
0
        public virtual ActionResult Register(GroupRegisterVM model)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            if (!currentMember.IsActive)
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "You must first activate an account with us before you can register a Group",
                    Title = ErrorStrings.TITLE_WARNING,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Home.Index()),
                };

                returnValue = View("Message", messageModel);
            }
            else if (ModelState.IsValid)
            {
                ProviderGroup aGroup = new ProviderGroup();
                if (!GroupBL.Save(model, aGroup))
                {
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Failed to activate group.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                        Title = "Group registration failure",
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index())
                    };
                    returnValue = View("Message", viewModel);
                }
                else
                {
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Success,
                        CssClassContainer = "info",
                        Message = "Your Group has been created:",
                        Title = "Group created",
                        Details = new List<string>
                        {
                            "<a href='" + Url.Action( MVC.Group.Details(aGroup.Id.Value) ) + "' class='button'>View</a>  your group",
                            "<a href='" + Url.Action( MVC.Group.Manage(aGroup.Id.Value) ) + "' class='button'>Manage</a> your group"
                        }
                    };
                    returnValue = View("Message", viewModel);
                }
            }

            if (returnValue == null)
            {
                returnValue = View(model);
            }

            return returnValue;
        }
Exemplo n.º 3
0
        public virtual ActionResult Account(long memberId, string issuedKey)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;

            // If we have all of the required data then try an authentication with the issued key
            if (!currentMember.IsLoggedOn && !string.IsNullOrEmpty(issuedKey))
            {
                List<string> errorList = new List<string>();
                if (currentMember.Login(issuedKey, null, false, ref errorList) != ProviderCurrentMember.LoginEnum.success)
                {
                    // failed for whatever reason
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Failed to login: "******"Continue",
                        LinkHref = Url.Action(MVC.Home.Index(null, null)),
                    };

                    returnValue = View("Message", viewModel);
                }
            }

            if (returnValue == null)
            {
                ProviderMember aMember = new ProviderMember(memberId);
                if (!currentMember.CanEdit(aMember))
                {
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Authorization Failure.  You may need to login or obtain access privileges to view this page.",
                        Title = "Authorization Failure",
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index(null, null))
                    };

                    returnValue = View("Message", viewModel);
                }
                else
                {
                    returnValue = View(new AccountVM(aMember, currentMember));
                }
            }

            return returnValue;
        }
Exemplo n.º 4
0
        public virtual ActionResult ArticleEdit(long? articleId, string issuedKey)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;

            // If we have all of the required data then try an authentication with the issued key
            if (!currentMember.IsLoggedOn &&  !string.IsNullOrEmpty(issuedKey))
            {
                List<string> errorList = new List<string>();
                if (currentMember.Login(issuedKey, null, false, ref errorList) != ProviderCurrentMember.LoginEnum.success )
                {
                    // failed for whatever reason
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Failed to login: "******"Continue",
                        LinkHref = Url.Action(MVC.Home.Index()),
                    };

                    returnValue = View("Message", viewModel);
                }
            }

            if(returnValue == null)
            {
                ProviderArticle anArticle = null;
                if (articleId.HasValue)
                {
                    anArticle = new ProviderArticle(articleId.Value);
                }
                else
                {
                    anArticle = new ProviderArticle();
                }

                if (!currentMember.CanEdit(anArticle))
                {
                    returnValue = RedirectToAction(MVC.Error.Index(401));
                }
                else
                {
                    returnValue = PartialView(new ArticleEditVM(anArticle));
                }
            }

            return returnValue;
        }
Exemplo n.º 5
0
        public virtual ActionResult AddMedia(AddMediaVM.AddMediaPurpose purpose, AddMediaVM.AddMediaType type, long? memberId)
        {
            ActionResult returnValue = null;
            AddMediaVM viewModel = new AddMediaVM
            {
                Type = type,
                Purpose = purpose
            };
            if (purpose == AddMediaVM.AddMediaPurpose.TinyMce || purpose == AddMediaVM.AddMediaPurpose.ProfileImageAjax)
            {
                returnValue = View(MVC.Shared.Views.AddMediaStandalone, viewModel);
            }
            else if (purpose == AddMediaVM.AddMediaPurpose.ProfileImage)
            {
                returnValue = View("AddMedia", viewModel);
            }
            else
            {
                if (this.Request.IsAjaxRequest())
                {
                    var viewModelError = new AjaxReturnMsgVM
                    {
                        StatusCode = AjaxReturnMsgVM.Status.failure,
                        StatusMessage = "Unsupported purpose"
                    };

                    returnValue = Json(viewModelError);
                }
                else
                {
                    var viewModelError = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Unsupported purpose ",
                        Title = ErrorStrings.TITLE_ERROR,
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index()),
                    };

                    returnValue = View("Message", viewModelError);
                }
            }

            return returnValue;
        }
Exemplo n.º 6
0
        // GET: /Error/errorCode
        public virtual ActionResult Index(int? errorCode)
        {
            string errorMessage = string.Empty;
            if (errorCode.HasValue)
            {
                errorMessage = ErrorStrings.HtmlErrorCode(errorCode.Value);
            }
            else
            {
                errorMessage = "Unknown error";
            }

            var viewModel = new MessageVM
            {
                Image = ImageLibrary.Alert,
                CssClassContainer = "failure",
                Message = errorMessage + "<br />Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                Title = ErrorStrings.TITLE_ERROR,
                LinkText = "Continue",
                LinkHref = Url.Action( MVC.Home.Index() ),
            };

            return View( MVC.Shared.Views.Message, viewModel);
        }
Exemplo n.º 7
0
 public virtual ActionResult ResetPasswordRequestComplete()
 {
     var viewModel = new MessageVM
     {
         Image = ImageLibrary.CheckEmail,
         CssClassContainer = "info",
         Message = "You will receive an e-mail shortly.  Follow the link provided in the email to reset your password.",
         Title = "Reset Your Password",
         LinkText = "Continue",
         LinkHref = Url.Action(MVC.Home.Index())
     };
     return View("Message", viewModel);
 }
Exemplo n.º 8
0
        public virtual ActionResult RequestValidateEmail(string newEmail, long memberId)
        {
            ActionResult returnValue = null;
            MailAddress mailAddress = null;

            // check if email is unique and try to parse it
            // if unique (not taken) and valid format (and thus not validated) then send activation email
            if (!IWStringUtility.TryParse(newEmail, out mailAddress))
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "Invalid e-mail",
                    Title = ErrorStrings.TITLE_ERROR,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Member.Account(memberId, null)),
                };
                returnValue = View("Message", messageModel);
            }
            else if (ProviderEmail.FindOwner(mailAddress, true) != null)
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "E-mail is already taken.",
                    Title = ErrorStrings.TITLE_ERROR,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Member.Account(memberId, null)),
                };
                returnValue = View("Message", messageModel);
            }
            else if (!ProviderMember.Exists(memberId))
            {
                MessageVM messageModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "No member with id "+memberId,
                    Title = ErrorStrings.TITLE_ERROR,
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Member.Account(memberId, null)),
                };
                returnValue = View("Message", messageModel);
            }
            else
            {
                ProviderMember member = new ProviderMember(memberId);
                ProviderEmail anEmail = new ProviderEmail();
                anEmail.MemberId = memberId;
                anEmail.IsValidated = false;
                anEmail.CreateDate = DateTime.UtcNow;
                anEmail.EditDate = DateTime.UtcNow;
                anEmail.Email = mailAddress;
                anEmail.Save();

                EmailManager.Instance.SendActivationEmail(mailAddress, member);

                returnValue = RedirectToAction(MVC.Member.EmailValidationSent());
            }

            return returnValue;
        }
Exemplo n.º 9
0
        // GET: /member/registercomplete
        public virtual ActionResult RegisterComplete()
        {
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            MessageVM viewModel = new MessageVM
            {
                Image = ImageLibrary.Success,
                CssClassContainer = "info",
                Message = "Welcome! Your account has been activated.  Explore our site:",
                Title = "Account Activated",
                Details = new List<string>
                {
                    "<a href='" + Url.Action( MVC.Home.Index(null, null) ) + "' class='button'>Home Page</a> Go back to the main page.",
                    "<a href='" + Url.Action( MVC.Article.ArticleEdit(null, null) ) + "' class='button'>Publish</a> Become an author!  Publish an article.",
                    "<a href='" + Url.Action( MVC.Member.Profile(currentMember.Id.Value, null) ) + "' class='button'>Profile</a> Check out your new member profile " +
                    "where you can review your published articles and add details to show others who you are."
                }
            };

            return View("Message", viewModel);
        }
Exemplo n.º 10
0
        // GET: member/profile/{memberId}/{page}
        public virtual ActionResult Profile(long memberId, int? page)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            ProviderMember aMember = new ProviderMember(memberId);
            if (aMember.IsAnonymous && !currentMember.CanEdit(aMember))
            {
                if (currentMember.Owns(aMember))
                {
                    MessageVM viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "success",
                        Message = "Your profile doesn't exist yet! Choose a password and finish <a href='" + Url.Action(MVC.Member.ChangePassword()) + "' class='button'>activating</a> your account to get one.",
                        Title = "Info",
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index(null, null))
                    };
                    return View(MVC.Shared.Views.Message, viewModel);
                }
                else
                {
                    returnValue = RedirectToAction(MVC.Error.Index(404));
                }
            }
            else
            {
                int nPage = page ?? 0;
                returnValue = View(new ProfileVM(aMember, currentMember, nPage));
            }

            return returnValue;
        }
Exemplo n.º 11
0
 // GET: /member/email_validation_sent
 public virtual ActionResult EmailValidationSent()
 {
     MessageVM viewModel = new MessageVM
     {
         Image = ImageLibrary.CheckEmail,
         CssClassContainer = "info",
         Message = "You will receive an e-mail shortly.  Follow the link provided in the email to validate your email.",
         Title = "Email Validation",
         LinkText = "Continue",
         LinkHref = Url.Action(MVC.Home.Index())
     };
     return View("Message", viewModel);
 }
Exemplo n.º 12
0
        public virtual ActionResult AddMedia(AddMediaVM model)
        {
            ActionResult returnValue = null;
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            ProviderMember aMember = null;

            // try to get the member from the model, otherwise just use current member
            // TODO check this logic
            if (model.MemberId != null)
            {
                aMember = new ProviderMember(model.MemberId.Value);
            }
            else
            {
                aMember = currentMember;
            }

            HttpPostedFileBase filePhoto = Request.Files[model.FilePhotoKey] as HttpPostedFileBase;
            bool isValidPhoto = ProviderPhoto.Validate(filePhoto);
            ProviderPhoto originalPhoto = null;

            if (isValidPhoto)
            {
                originalPhoto = PhotoBL.CreatePhoto(aMember, filePhoto);
            }

            if (model.Purpose == AddMediaVM.AddMediaPurpose.TinyMce)
            {
                if (isValidPhoto)
                {
                    returnValue = View("AddMediaDone", new AddMediaDoneVM { FileURL = originalPhoto.ImageUrl.AbsoluteUri });
                }
                else
                {
                    ModelState.AddModelError("", ErrorStrings.INVALID_IMAGE);
                    returnValue = View(MVC.Shared.Views.AddMediaStandalone, model);
                }
            }
            else if (model.Purpose == AddMediaVM.AddMediaPurpose.ProfileImage || model.Purpose == AddMediaVM.AddMediaPurpose.ProfileImageAjax)
            {
                if(isValidPhoto)
                {
                    aMember.ProfilePhotoId = originalPhoto.Id;
                    aMember.Save();
                }

                if (model.Purpose == AddMediaVM.AddMediaPurpose.ProfileImageAjax)
                {
                    var viewModel = new AjaxReturnMsgVM();
                    if(isValidPhoto)
                    {
                        viewModel.StatusCode = AjaxReturnMsgVM.Status.success;
                        viewModel.StatusMessage = originalPhoto.Thumbnail(ProviderPhotoRecord.ImageTypeEnum.ProfileThumbnail)
                                                               .ImageUrl
                                                               .AbsoluteUri;
                    }
                    else
                    {
                        viewModel.StatusCode = AjaxReturnMsgVM.Status.failure;
                        viewModel.StatusMessage = ErrorStrings.INVALID_IMAGE;
                    }
                    returnValue = Json(viewModel);
                }
                else if (model.Purpose == AddMediaVM.AddMediaPurpose.ProfileImage)
                {
                    if (isValidPhoto)
                    {
                        var viewModel = new MessageVM
                        {
                            Image = ImageLibrary.Success,
                            CssClassContainer = "success",
                            Message = "Profile Image updated",
                            Title = "Profile Image updated",
                            LinkText = "Continue",
                            LinkHref = Url.Action(MVC.Member.Account(aMember.Id.Value, null)),
                        };
                        returnValue = View("Message", viewModel);
                    }
                    else
                    {
                        ModelState.AddModelError("", ErrorStrings.INVALID_IMAGE);
                        returnValue = View(model);
                    }
                }
            }
            else
            {
                if(this.Request.IsAjaxRequest())
                {
                    var viewModel = new AjaxReturnMsgVM
                    {
                        StatusCode = AjaxReturnMsgVM.Status.failure,
                        StatusMessage = "Unsupported purpose"
                    };

                    returnValue = Json(viewModel);
                }
                else
                {
                    var viewModel = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Unsupported purpose ",
                        Title = ErrorStrings.TITLE_ERROR,
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index()),
                    };

                    returnValue = View("Message", viewModel);
                }
            }

            return returnValue;
        }
Exemplo n.º 13
0
        public virtual ActionResult ChangePasswordComplete()
        {
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;

            var viewModel = new MessageVM
            {
                Image = ImageLibrary.Success,
                CssClassContainer = "success",
                Message = "Your password has been changed successfully.",
                Title = "Change Password",
                LinkText = "Continue",
                LinkHref = Url.Action(MVC.Member.Profile(currentMember.Id.Value, null))
            };
            return View("Message", viewModel);
        }
Exemplo n.º 14
0
 // override OnAuthorization to redirect to any action we want (such as ErrorController) if not authorized.
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     base.OnAuthorization(filterContext);
     if (FailedAuth)
     {
         var viewModel = new MessageVM
         {
             Image = ImageLibrary.Alert,
             CssClassContainer = "failure",
             Message = "Authorization Failure.  You may need to login or obtain access privileges to view this page.",
             Title = "Authorization Failure",
             LinkText = "Continue",
             LinkHref = "/"
         };
         filterContext.Result = new ViewResult { ViewName = "Message", ViewData = new ViewDataDictionary(viewModel) };
     }
 }
Exemplo n.º 15
0
        public virtual ActionResult LoginOpenIdProcess()
        {
            OpenIdRelyingParty openid = new OpenIdRelyingParty();
            IAuthenticationResponse response = openid.GetResponse();
            ActionResult returnValue = null;

            if (response == null)
            {
                MessageVM viewModel = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "We could not log you in with your chosen OpenId.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                    Title = "Login failure",
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Home.Index())
                };
                returnValue = View(MVC.Shared.Views.Message, viewModel);
            }
            else
            {
                MessageVM viewModel = null;
                switch (response.Status)
                {
                    case AuthenticationStatus.Authenticated:
                        ClaimsResponse sreg = response.GetExtension<ClaimsResponse>();
                        string openId = response.ClaimedIdentifier.ToString();
                        string host = response.Provider.Uri.Host;
                        MailAddress email = null;
                        if (sreg != null)
                        {
                            email = new MailAddress(sreg.Email);
                        }

                        // Create or update a member with this information.
                        MemberBL.UpdateMemberOpenId(openId, email, host);

                        ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
                        List<string> errorList = new List<string>();
                        if (currentMember.Login(openId, null, true, ref errorList) != ProviderCurrentMember.LoginEnum.success)
                        {
                            viewModel = new MessageVM
                            {
                                Image = ImageLibrary.Alert,
                                CssClassContainer = "failure",
                                Message = "We could not log you in with your chosen OpenId.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                                Title = "Login failure",
                                LinkText = "Continue",
                                LinkHref = Url.Action(MVC.Home.Index()),
                                Details = errorList
                            };
                            returnValue = View(MVC.Shared.Views.Message, viewModel);
                        }
                        else
                        {
                            string previousUrl = Session[_loginPreviousPageKey] as string;
                            if (string.IsNullOrWhiteSpace(previousUrl))
                            {
                                returnValue = RedirectToAction(MVC.Home.Index());
                            }
                            else
                            {
                                returnValue = Redirect(previousUrl);
                            }
                        }
                        break;

                    case AuthenticationStatus.Canceled:
                        viewModel = new MessageVM
                        {
                            Image = ImageLibrary.Alert,
                            CssClassContainer = "failure",
                            Message = "Login was cancelled by your OpenId provider.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                            Title = "Login failure",
                            LinkText = "Continue",
                            LinkHref = Url.Action(MVC.Home.Index())
                        };
                        returnValue = View(MVC.Shared.Views.Message, viewModel);
                        break;

                    case AuthenticationStatus.Failed:
                        InsideWordWebLog.Instance.Log.Error(response.Exception);
                        viewModel = new MessageVM
                        {
                            Image = ImageLibrary.Alert,
                            CssClassContainer = "failure",
                            Message = "We could not log you in with your chosen OpenId.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                            Title = "Login failure",
                            LinkText = "Continue",
                            LinkHref = Url.Action(MVC.Home.Index())
                        };
                        returnValue = View(MVC.Shared.Views.Message, viewModel);
                        break;
                }
            }
            return returnValue;
        }
Exemplo n.º 16
0
        // GET: /member/validate
        public virtual ActionResult ValidateEmail(string key)
        {
            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            List<string> errorList = new List<string>();
            ProviderIssuedKey nonceKey = new ProviderIssuedKey();
            MessageVM returnMessageVM = new MessageVM
            {
                Image = ImageLibrary.Alert,
                CssClassContainer = "failure",
                Message = "Failed to validate e-mail.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                Title = "E-mail Validation Failure",
                LinkText = "Continue",
                LinkHref = Url.Action(MVC.Home.Index()),
                Details = errorList
            };

            if (nonceKey.Load(key))
            {
                ProviderEmail anEmail = new ProviderEmail();
                if (anEmail.Load(nonceKey.Data))
                {
                    anEmail.IsValidated = true;
                    anEmail.EditDate = DateTime.UtcNow;
                    anEmail.Save();

                    if (currentMember.IsLoggedOn && currentMember.IsActive)
                    {
                        returnMessageVM = new MessageVM
                        {
                            Image = ImageLibrary.Success,
                            CssClassContainer = "info",
                            Message = "Your e-mail has been validated",
                            Title = "E-mail validated"
                        };
                    }
                    else if (currentMember.Login(key, null, false, ref errorList) == ProviderCurrentMember.LoginEnum.success)
                    {
                        returnMessageVM = new MessageVM
                        {
                            Image = ImageLibrary.Success,
                            CssClassContainer = "info",
                            Message = "Welcome! Your account has been activated.  Explore our site:",
                            Title = "Account Activated",
                            Details = new List<string>
                            {
                                "<a href='" + Url.Action( MVC.Home.Index(null, null) ) + "' class='button'>Home Page</a> Go back to the main page.",
                                "<a href='" + Url.Action( MVC.Article.ArticleEdit(null, null) ) + "' class='button'>Publish</a> Become an author!  Publish an article.",
                                "<a href='" + Url.Action( MVC.Member.Profile(currentMember.Id.Value, null) ) + "' class='button'>Profile</a> Check out your new member profile " +
                                "where you can review your published articles and add details to show others who you are."
                            }
                        };
                    }
                }
            }

            return View("Message", returnMessageVM);
        }
Exemplo n.º 17
0
        // GET: /member/ChangePassword
        public virtual ActionResult ChangePassword(string issuedKey)
        {
            ActionResult returnValue = null;

            ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;
            if (!string.IsNullOrWhiteSpace(issuedKey))
            {
                ProviderIssuedKey aKey = new ProviderIssuedKey();
                if (!aKey.Load(issuedKey))
                {
                    MessageVM returnMessageVM = new MessageVM
                    {
                        Image = ImageLibrary.Alert,
                        CssClassContainer = "failure",
                        Message = "Invalid key provided.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                        Title = "Login failure",
                        LinkText = "Continue",
                        LinkHref = Url.Action(MVC.Home.Index())
                    };
                    returnValue = View(MVC.Shared.Views.Message, returnMessageVM);
                }
                else
                {
                    // validate the e-mail if it wasn't already.
                    ProviderEmail anEmail = new ProviderEmail();
                    if (anEmail.Load(aKey.Data) && !anEmail.IsValidated)
                    {
                        anEmail.IsValidated = true;
                        anEmail.EditDate = DateTime.UtcNow;
                        anEmail.Save();
                    }

                    List<string> errorList = new List<string>();
                    if (currentMember.Login(issuedKey, null, false, ref errorList) == ProviderCurrentMember.LoginEnum.success)
                    {
                        MessageVM returnMessageVM = new MessageVM
                        {
                            Image = ImageLibrary.Alert,
                            CssClassContainer = "failure",
                            Message = "Failed to login.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                            Title = "Login failure",
                            LinkText = "Continue",
                            LinkHref = Url.Action(MVC.Home.Index()),
                            Details = errorList
                        };
                        returnValue = View(MVC.Shared.Views.Message, returnMessageVM);
                    }
                }
            }

            if(currentMember.IsLoggedOn)
            {
                ChangePasswordVM viewModel = new ChangePasswordVM
                {
                    CurrentMemberId = currentMember.Id.Value
                };
                returnValue = View(viewModel);
            }

            return returnValue;
        }
Exemplo n.º 18
0
        // POST: /member/delete
        public virtual ActionResult Delete(string key)
        {
            MessageVM returnMessageVM;
            ProviderIssuedKey issuedKey = new ProviderIssuedKey();

            if (issuedKey.Load(key) && !issuedKey.HasExpired && issuedKey.IsValidated)
            {
                ProviderMember aMember = new ProviderMember(issuedKey.MemberId);
                ProviderCurrentMember currentMember = ProviderCurrentMember.Instance;

                // if the person is currently logged on with the account that is being deleted then log them off
                if (currentMember.Id == aMember.Id)
                {
                    currentMember.LogOff();
                }

                aMember.Delete();

                returnMessageVM = new MessageVM
                {
                    Image = ImageLibrary.Success,
                    CssClassContainer = "success",
                    Message = "Success! Member Acount deleted.",
                    Title = "Acount Deleted",
                    LinkText = "Continue",
                    LinkHref = Url.Action(MVC.Home.Index())
                };
            }
            else
            {
                returnMessageVM = new MessageVM
                {
                    Image = ImageLibrary.Alert,
                    CssClassContainer = "failure",
                    Message = "Failed to delete member account.  Please <a href=\"" + Url.Action(MVC.Info.ContactUs()) + "\">contact us</a> to resolve the issue.",
                    Title = "Account Deletion Failure",
                    LinkText = "Continue",
                    LinkHref = Url.Action( MVC.Home.Index() )
                };
            }

            return View("Message", returnMessageVM);
        }