Beispiel #1
0
 public function signIn(array $userDetails)
 {
     $pl = new PlayerByUsernamePassword($userDetails['username'], $userDetails['password']);
     if ($pl->getId()) {
         $this->setUserId($pl->getId());
         $this->commit();
         $this->setCookie($userDetails);
         return array('token' => $this->getKey(), 'access' => $pl->getUserAccess());
     }
     throw new LudoDBUnauthorizedException("Invalid username or password");
 }
 /**
  * @test
  */
 public function shouldBeAbleToFindPlayerByUsernameAndPassword()
 {
     // given
     $this->createUser('user1', 'pass1');
     // when
     $user = new PlayerByUsernamePassword('user1', md5('pass1'));
     // then
     $this->assertEquals(2, $user->getId());
     $this->assertEquals('user1', $user->getUsername());
     $this->assertEquals(md5('pass1'), $user->getPassword());
 }