Ejemplo n.º 1
0
        public LoginResponse RecoverPassword(string code, string password)
        {
            var recovery = Data.Get(code);

            if (recovery == null)
            {
                throw new BusinessException("There is no request for recover password.");
            }
            if (Data.GetDateTimeNow() > recovery.CreationDate.AddMinutes(60))
            {
                throw new BusinessException("Recover password code is expired.");
            }

            var user = UserBusiness.GetForLoginById(recovery.UserId);

            UserBusiness.UpdatePassword(user, password);

            bool hasInvestment = UserBusiness.GetUserHasInvestment(user);

            return(new LoginResponse()
            {
                Id = user.Id,
                Email = user.Email,
                PendingConfirmation = !user.ConfirmationDate.HasValue,
                IsAdvisor = UserBusiness.IsValidAdvisor(user),
                AdvisorName = UserBusiness.GetAdvisorName(user),
                ProfileUrlGuid = UserBusiness.GetProfileUrlGuid(user),
                HasInvestment = hasInvestment
            });
        }
Ejemplo n.º 2
0
        public void RecoverPassword(string code, string password)
        {
            var recovery = Data.Get(code);

            if (recovery == null)
            {
                throw new ArgumentException("There is no request for recover password.");
            }
            if (DateTime.UtcNow > recovery.Date.AddMinutes(60))
            {
                throw new ArgumentException("Recover password code is expired.");
            }

            UserBusiness.UpdatePassword(UserBusiness.Get(recovery.UserId), password);
        }