public bool Insert(int userId, string code, int timeExpiration) { UserRestoreEntity userRestoreEntity = new UserRestoreEntity(); userRestoreEntity.IdUser = userId; userRestoreEntity.Code = code; userRestoreEntity.CreatedDate = DateTime.Now; userRestoreEntity.ExpirationDate = userRestoreEntity.CreatedDate.AddSeconds(timeExpiration); return (_UserRestoreCrud.Insert(userRestoreEntity)); }
public bool IsValidCode(string email, string code, out string errorMessage) { UserLogic userLogic = new UserLogic(); UserEntity userEntity = userLogic.SelectByLoginName(email); bool isValidCode = false; errorMessage = string.Empty; if (userEntity != null) { UserRestoreEntity userRestoreEntity = this.SelectByUserIdCode(userEntity.Id, code); if (userRestoreEntity != null) { /* Se valida que el codigo no haya expirado */ if (userRestoreEntity.ExpirationDate > DateTime.Now) { isValidCode = true; } else { errorMessage = "El codigo se encuentra vencido"; } } else { errorMessage = "Fallo en la autenticidad del codigo a la cuenta asociada"; } } else { errorMessage = "No existe ninguna cuenta con ese correo electronico"; } return isValidCode; }