Giter Club home page Giter Club logo

goalioremembermedoctrineorm's Introduction

GoalioRememberMeDoctrineORM

Doctrine2 ORM storage adapter for GoalioRememberMe.

goalioremembermedoctrineorm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

goalioremembermedoctrineorm's Issues

GoalioRememberMeDoctrineORM\Repository\RememberMe not found

An error occurs when a user wants to log out after a rememberMe connection.

Undefined method 'deleteByUidAndSid'. The method name must start with either findBy or findOneBy!

Explication :
In RememberMe Mapper class, the expression "$this->em->getRepository($this->options->getRememberMeEntityClass());" return a "Doctrine\ORM\EntityRepository"
but the expected class is "GoalioRememberMeDoctrineORM\Repository\RememberMe".

I can't find a fix ... That's why a propose to migrate the "GoalioRememberMeDoctrineORM\Repository\RememberMe" functions content directly in RememberMe Mapper.

Loading the Metadata for GoalioRememberMeDoctrineORM\Entity\RememberMe

there seems to be a problem because the onbootstrap of the GoalioRememberMeModuleORM (where an authenticate event is triggered) is called after the one of the GoalioRememberMe module (where the entity xml configuration for the entity GoalioRememberMeDoctrineORM\Entity\RememberMe is loaded : i have got this error :

Fatal error: Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'The class 'GoalioRememberMeDoctrineORM\Entity\RememberMe' was not found in the chain configured namespaces XXX' in X\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\MappingException.php:38 Stack trace: #0 X\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain.php(114): Doctrine\Common\Persistence\Mapping\MappingException::classNotFoundInNamespaces('GoalioRememberM...', Array) #1 X\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php(113): Doctrine\Common\Persistence\Mappin in X\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\MappingException.php on line 38

i solved the problem in uncommenting the line 'remember_me_entity_class' => 'GoalioRememberMe\Entity\RememberMe' in the goaliorememberme.global.php config...but I am not sure it is the best solution....

Install with composer

Hi, how is it possible to install it with composer?
I tried using:

"goalio/goalio-rememberme-doctrine-orm": "dev-master",

without success...

ZfcUser 1.0.0 update

Could you update dependency of this to work with ZfcUser 1.0.0? It says that it need ZfcUser 0.1.1.

Thanks

Tag version

Could you tag a new version? Last stable (0.1) is not working. Thank a lot :-)

doctrine primary key needed

It seems as if doctrine needs a primary key for each entity therefore i would suggest in the file GoalioRememberMe.Entity.RememberMe.dcm.xml
to change the sid field iinto an id :

typos namespace, doctrine config

  1. namespace in GoalioRememberMeDoctrineORM\Options\ModuleOptions has a typo
  2. in module.config.php, i think the configuration should be (no 'DoctrinORM in the orm_default config)

'doctrine' => array(
'driver' => array(
'goaliorememberme_entity' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\XmlDriver',
'paths' => DIR . '/xml/goaliorememberme'
),
'orm_default' => array(
'drivers' => array(
'GoalioRememberMe\Entity' => 'goaliorememberme_entity'
)
)
)

RememberMe Mapper must be refactored to avoid sql injections problem

Hi,

Concatenating strings to build a query is dangerous! The user could use it's cookie value to inject malicious code.

In Mapper\RememberMe:

public function removeAll($userId)
{
    $dql = sprintf("DELETE %s u WHERE u.user_id = %s", $this->options->getRememberMeEntityClass(), $userId);
    $query = $this->em->createQuery($dql);
    $query->getResult();
}

public function removeSerie($userId, $serieId)
{
    $dql = sprintf("DELETE %s u WHERE u.user_id = %s AND u.sid = '%s'", $this->options->getRememberMeEntityClass(), $userId, $serieId);
    $query = $this->em->createQuery($dql);
    $query->getResult();
}

Should be replaced by :

public function removeAll($userId)
{
    $er = $this->em->getRepository($this->options->getRememberMeEntityClass());
    return $er->deleteByUid($userId);
}

public function removeSerie($userId, $serieId)
{
    $er = $this->em->getRepository($this->options->getRememberMeEntityClass());
    return $er->deleteByUidAndSid($userId,$serieId);
}

Then in our entity repository we add :

public function deleteByUid($uid)
{
    $qb = $this->getEntityManager()->createQueryBuilder();
    $qb->delete('RememberMe','r')
        ->where('r.uid = :uid')
        ->setParameter('uid', $uid);
    return $qb->getQuery()->getSingleScalarResult();
}

public function deleteByUidAndSid($uid,$sid)
{
    $qb = $this->getEntityManager()->createQueryBuilder();
    $qb->delete('RememberMe','r')
    ->where('r.uid = :uid')
    ->andWhere('r.sid = :sid')
    ->setParameter('uid', $uid)
    ->setParameter('sid', $sid);
    return $qb->getQuery()->getSingleScalarResult();
}

The main advantage of moving the query building work to the repository is that it makes the mapper db-agnostic as it relies on the entity repository for every call. Not just for the select calls, as it is today in your version. It's more coherent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.