public async Task <Feedback> forgot(string tenant, string email)
        {
            Feedback feedback = new Feedback();

            try
            {
                AppNotification notification;
                notification = new AppNotification()
                {
                    type     = _userRepo.GetInstance(tenant).tableName,
                    message  = "Forgot Password Email Sending",
                    progress = 0
                };
                _notificationRepo.GetInstance(tenant).save(ref notification);
                _hubContext.Clients.All.SendAsync("SendNotification", notification);
                try
                {
                    var _userData = _userRepo.GetInstance(tenant).getByUserName(email);
                    if (_userData != null)
                    {
                        using (var transaction = DBServer.BeginTransaction())
                        {
                            _userData.otp = TokenGenerater.generateToken(7);
                            _userRepo.GetInstance(tenant).save(ref _userData, transaction);
                            //Email.Send(email, "Forgot Password", "Please reset your password:"******"Forgot password email sent sucessfully";
                            _notificationRepo.GetInstance(tenant).save(ref notification);
                            _hubContext.Clients.All.SendAsync("SendNotification", notification);
                            feedback = new Feedback
                            {
                                Code    = 1,
                                Message = "Forgot password email sent sucessfully",
                                data    = email
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    notification.progress = -1;
                    notification.message  = "Got the error while sending reset password email";
                    _notificationRepo.GetInstance(tenant).save(ref notification);
                    _hubContext.Clients.All.SendAsync("SendNotification", notification);
                    feedback = new Feedback
                    {
                        Code    = 0,
                        Message = "Got the error while sending reset password email",
                        data    = ex
                    };
                    GitHub.createIssue(ex, new { tenant = tenant, data = email }, _accessor.HttpContext.Request.Headers);
                }
            }
            catch (Exception ex)
            {
                GitHub.createIssue(ex, new { tenant = tenant, data = email }, _accessor.HttpContext.Request.Headers);
            }
            return(feedback);
        }
Exemple #2
0
 /// <summary>
 /// 账户管理
 /// </summary>
 /// <param name="signInManager"></param>
 /// <param name="aspNetUserManager"></param>
 /// <param name="emailSender"></param>
 /// <param name="smsSender"></param>
 /// <param name="tokenGenerater"></param>
 /// <param name="tokenManager"></param>
 public AccountController(SignInManager signInManager, AspNetUserManager aspNetUserManager, IEmailSender emailSender,
                          ISmsSender smsSender, TokenGenerater tokenGenerater, TokenManager tokenManager)
 {
     _signInManager      = signInManager;
     _userManager        = aspNetUserManager;
     _emailSender        = emailSender;
     _smsSender          = smsSender;
     this.tokenGenerater = tokenGenerater;
     this.tokenManager   = tokenManager;
 }