Esempio n. 1
0
        public virtual async Task <ActionResult> Index()
        {
            var user = await _queries.Execute(new UserViewBy(User.Identity.GetUserId <int>()));

            var emails = await _queries.Execute(new EmailAddressViewsBy(User.Identity.GetUserId <int>())
            {
                OrderBy = new Dictionary <Expression <Func <EmailAddressView, object> >, OrderByDirection>
                {
                    { x => x.IsPrimary, OrderByDirection.Descending },
                    { x => x.IsVerified, OrderByDirection.Descending },
                },
            });

            var model = new EmailAddressSettingsModel
            {
                UserView              = user,
                EmailAddresses        = emails.ToArray(),
                SendVerificationEmail = new SendVerificationEmail
                {
                    Purpose         = EmailVerificationPurpose.AddEmail,
                    SendFromUrl     = Url.AbsoluteAction(await MVC.UserEmails.Index()),
                    VerifyUrlFormat = Url.AbsoluteActionFormat(await MVC.UserEmailConfirm.Index("{0}", "{1}")),
                },
            };

            ViewBag.ActionUrl = Url.Action(MVC.UserEmails.Post());
            ViewBag.Purpose   = model.SendVerificationEmail.Purpose;
            return(View(MVC.Security.Views.User.EmailAddresses, model));
        }
Esempio n. 2
0
 public virtual ViewResult Index(string returnUrl)
 {
     ViewBag.ReturnUrl       = returnUrl;
     ViewBag.ActionUrl       = Url.Action(MVC.SignUpSendEmail.Post());
     ViewBag.Purpose         = EmailVerificationPurpose.CreateLocalUser;
     ViewBag.VerifyUrlFormat = Url.AbsoluteActionFormat(MVC.SignUpCreateUser.Index("{0}", "{1}", returnUrl).Result);
     ViewBag.SendFromUrl     = Url.AbsoluteAction(MVC.SignUpSendEmail.Index(returnUrl));
     return(View(MVC.Security.Views.SignUp.SendEmail));
 }
 public virtual ActionResult Index(string returnUrl)
 {
     ViewBag.ReturnUrl       = returnUrl;
     ViewBag.Purpose         = EmailVerificationPurpose.ForgotPassword;
     ViewBag.VerifyUrlFormat = Url.AbsoluteActionFormat(
         MVC.ResetPassword.Index("{0}", "{1}", returnUrl).Result);
     ViewBag.SendFromUrl = Url.AbsoluteAction(
         MVC.ResetPasswordSendEmail.Index(returnUrl));
     return(View(MVC.Security.Views.ResetPassword.SendEmail));
 }
Esempio n. 4
0
        public virtual async Task <ActionResult> Post(SendVerificationEmail command)
        {
            if (command == null || command.Purpose == EmailVerificationPurpose.Invalid)
            {
                return(View(MVC.Errors.Views.BadRequest));
            }

            if (!ModelState.IsValid)
            {
                var user = await _queries.Execute(new UserViewBy(User.Identity.GetUserId <int>()));

                var emails = await _queries.Execute(new EmailAddressViewsBy(User.Identity.GetUserId <int>())
                {
                    OrderBy = new Dictionary <Expression <Func <EmailAddressView, object> >, OrderByDirection>
                    {
                        { x => x.IsPrimary, OrderByDirection.Descending },
                        { x => x.IsVerified, OrderByDirection.Descending },
                    },
                });

                var model = new EmailAddressSettingsModel
                {
                    UserView              = user,
                    EmailAddresses        = emails.ToArray(),
                    SendVerificationEmail = command,
                };

                TempData.Alerts("**Could not send verification email due to error(s) below.**", AlertFlavor.Danger);
                ViewBag.ActionUrl = Url.Action(MVC.UserEmails.Post());
                return(View(MVC.Security.Views.User.EmailAddresses, model));
            }

            command.VerifyUrlFormat = Url.AbsoluteActionFormat(await MVC.UserEmailConfirm.Index("{0}", "{1}"));
            command.SendFromUrl     = Url.AbsoluteAction(await MVC.UserEmails.Index());
            await _commands.Execute(command);

            Session.VerifyEmailTickets(command.CreatedTicket);

            return(RedirectToAction(await MVC.UserEmailVerifySecret.Index(command.CreatedTicket)));
        }
        public virtual async Task <ActionResult> Post(SendVerificationEmail command, string returnUrl)
        {
            if (command == null || command.Purpose == EmailVerificationPurpose.Invalid)
            {
                return(View(MVC.Errors.Views.BadRequest));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.ReturnUrl = returnUrl;
                return(View(MVC.Security.Views.ResetPassword.SendEmail, command));
            }

            command.VerifyUrlFormat = Url.AbsoluteActionFormat(
                MVC.ResetPassword.Index("{0}", "{1}", returnUrl).Result);
            command.SendFromUrl = Url.AbsoluteAction(
                MVC.ResetPasswordSendEmail.Index(returnUrl));
            await _commands.Execute(command);

            Session.VerifyEmailTickets(command.CreatedTicket);

            return(RedirectToAction(await MVC.ResetPasswordVerifySecret.Index(command.CreatedTicket, returnUrl)));
        }