コード例 #1
0
        public async Task <ActionResult> ForgotLogin(ForgotPassword formModel)
        {
            TryValidateModel(formModel);
            if (!ModelState.IsValid)
            {
                return(View("customers/forgot_login", WorkContext));
            }

            var user = await _signInManager.UserManager.FindByEmailAsync(formModel.Email);

            if (user != null)
            {
                var remindUserNameNotification = new RemindUserNameNotification(WorkContext.CurrentStore.Id, WorkContext.CurrentLanguage)
                {
                    UserName  = user.UserName,
                    Sender    = WorkContext.CurrentStore.Email,
                    Recipient = GetUserEmail(user)
                };

                var sendingResult = await SendNotificationAsync(remindUserNameNotification);

                if (sendingResult.IsSuccess != true)
                {
                    WorkContext.Form.Errors.Add(new FormError {
                        Description = sendingResult.ErrorMessage
                    });
                }
            }
            else
            {
                WorkContext.Form.Errors.Add(SecurityErrorDescriber.UserNotFound());
            }

            return(View("customers/forgot_login", WorkContext));
        }
コード例 #2
0
        public async Task <ActionResult> ForgotLogin(ForgotPassword formModel)
        {
            var user = await _signInManager.UserManager.FindByEmailAsync(formModel.Email);

            if (user != null)
            {
                var remindUserNameNotification = new RemindUserNameNotification(WorkContext.CurrentStore.Id, WorkContext.CurrentLanguage)
                {
                    UserName  = user.UserName,
                    Sender    = WorkContext.CurrentStore.Email,
                    Recipient = GetUserEmail(user)
                };

                var sendingResult = await _platformNotificationApi.SendNotificationAsync(remindUserNameNotification.ToNotificationDto());

                if (sendingResult.IsSuccess != true)
                {
                    ModelState.AddModelError("form", sendingResult.ErrorMessage);
                }
            }
            else
            {
                ModelState.AddModelError("form", "User not found");
            }
            return(View("customers/forgot_login", WorkContext));
        }