Example #1
0
        public ActionResult UpdateEmail(AccountViewModel model)
        {            
            var response = BlogService.UpdateEmail(((BlogUser)User).UserId.Value, model.EmailAddress, TemplatePickupUrl);

            Notification notification;
            if (response.Success)
            {
                notification = new Notification
                {
                    Type = NotificationType.Information,
                    Subject = "Email Confirmation Required",
                    Message = "In order to confirm your email address, a verification email has been sent to the address you provided."
                };
            }
            else
            {
                notification = new Notification
                {
                    Type = NotificationType.Error,
                    Subject = "Update Failed",
                    Message = "Your email address could not be updated; " + response.Message
                };
            }

            TempData.StoreNotification(notification);

            return RedirectToAction("Index");
        }
Example #2
0
        public ActionResult VerifyEmail(Guid id)
        {
            var response = BlogService.AttemptEmailInvitePickup(((BlogUser)User).UserId.Value, id);
            
            Notification notification;
            if (response.Success)
            {
                notification = new Notification
                {
                    Type = NotificationType.Confirmation,
                    Subject = "Email Verified",
                    Message = "Your email address has been verified. Thanks!"
                };
            }
            else
            {
                notification = new Notification
                {
                    Type = NotificationType.Error,
                    Subject = "Verification Failed",
                    Message = "Your email address could not be verified. " + response.Message
                };
            }
            TempData.StoreNotification(notification);

            return RedirectToAction("Index");
        }
Example #3
0
        public ActionResult ChangePassword(ChangePasswordViewModel viewModel)
        {
            var notification = new Notification();

            TryValidateModel(viewModel);

            if (viewModel.NewPassword != viewModel.ConfirmNewPassword)
            {
                ModelState.AddModelError("ConfirmNewPassword", "Passwords must match");
            }

            if (!ModelState.IsValid)
            {
                notification.Type = NotificationType.Error;
                notification.Subject = "Password Change Failed";
                notification.Message = "Inputs not acceptable";
            }
            else if (BlogService.ChangePassword(UserId, viewModel.OldPassword, viewModel.NewPassword))
            {
                notification.Type = NotificationType.Confirmation;
                notification.Subject = "Password Successfully Changed";
            }
            else
            {
                notification.Type = NotificationType.Error;
                notification.Subject = "Password Change Failed";
                notification.Message = "Old password did not match";
            }

            TempData.StoreNotification(notification);
            return View(new ChangePasswordViewModel());
        }
Example #4
0
 public static void StoreNotification(this TempDataDictionary tempData, Notification notification)
 {
     tempData["Notification"] = notification;
 }