Example #1
0
        public void SendPasswordResetToken(string email)
        {
            var user = FindUserByEmail(email);

            if (user == null)
            {
                throw new SimpleException(Strings.EmailNotReg);
            }
            user.PasswordResetToken = _hashService.CreateTokenWithUserId(user.UserId, Constants.PasswordResetTokenLen);
            user.PasswordExpiryTime = DateTime.UtcNow.Add(TimeSpan.FromHours(Constants.PasswordExpTimeHrs));
            UpdateUser(user);
            MailSrv.SendPreDefMailAsync(user, MailType.ForgotPassword, null);
        }
        public void SendEmailValidationToken(User user)
        {
            if (user.EmailConfirmedOn != null)
            {
                throw new SimpleException(string.Format("The email '{0}' is already confirmed", user.Email));
            }
            var token = _hashService.CreateTokenWithUserId(user.UserId, Constants.EmailVerificationTokenLen);

            user.EmailConfirmationToken = token;
            UpdateUser(user);
            MailSrv.SendPreDefMailAsync(user, MailType.EmailConfirmation, null);
            AddUserLog(user.UserId, "Email validation token send");
        }
        public User UpdateRegStatus(int userId, UserRegisterStatus status)
        {
            var user = _db.Users.Find(userId);

            if (user == null)
            {
                new SimpleException(Strings.UserNotFoundById, userId);
            }
            user.AccountStatus = status;
            user.ApprovedOn    = DateTime.UtcNow;
            _db.SaveChanges();
            if (status == UserRegisterStatus.Approved)
            {
                MailSrv.SendPreDefMailAsync(user, MailType.RegApproved, null);
            }
            AddUserLog(user.UserId, "Registration status updated : " + status.ToString());
            return(user);
        }