Exemplo n.º 1
0
        public static bool IsExpiredDateForResetPasssword(this ResetPasswordConfirmationInfo info)
        {
            int expirationMinutes = 30;

            TimeSpan timeSpan = DateTime.Now.Subtract(info.CreatedAt);

            return(timeSpan.TotalMinutes > expirationMinutes);
        }
Exemplo n.º 2
0
        public ResetPasswordConfirmationInfo GetConfirmationInfo(string email)
        {
            IQueryConstraints <ResetPasswordConfirmationInfo> constraints = new QueryConstraints <ResetPasswordConfirmationInfo>()
                                                                            .Where(x => x.Email == email);

            ResetPasswordConfirmationInfo result = queryRepository.Find(constraints).Items.ToList().LastOrDefault();

            return(result);
        }
Exemplo n.º 3
0
        public ResetPasswordConfirmationInfo Create(ResetPasswordConfirmationInfo entity)
        {
            ResetPasswordConfirmationInfo createdEntity = repository.Create(entity);

            if (createdEntity == null)
            {
                throw new RepositoryException("Entity not created");
            }

            Tracer.Log.EntityCreated(nameof(ResetPasswordConfirmationInfo), createdEntity.ResetPasswordConfirmationInfoId);

            return(createdEntity);
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            User user = UserService.Obj.FindByEmail(model.Email);

            if (user == null)
            {
                throw new BusinessRuleException(nameof(User), BusinessRules.UserNotFound);
            }

            string token = UserService.Obj.GeneratePasswordResetToken(user.Id);

            string resetCode = ResetCodeOperation.ProduceUserResetCode();
            ResetPasswordConfirmationInfo info = ResetPasswordConfirmationInfo.Create(token, model.Email, resetCode);

            ResetPasswordInformationService.Obj.Create(info);

            await UserService.Obj.SendResetValidationCode(model.Email, resetCode);

            return(Ok());
        }