예제 #1
0
 /**
  * {@inheritdoc }
  */
 public function get($key)
 {
     $tKey = $this->getKey($key);
     $tNow = $this->getTtl();
     $data = $this->collection->findOne(array('_id' => $tKey, 'ttl' => array('$gte' => $tNow)));
     if (isset($data)) {
         return $this->unPack($data['value']);
     }
     return false;
 }
 /**
  * Auth
  */
 public function connect(Request $request)
 {
     $email = $request->email;
     $password = $request->password;
     if (!empty($email) && !empty($password)) {
         $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
         $collection = new \MongoDB\Collection($manager, 'builders', 'account');
         if ($collection->count(["email" => $email]) == 0) {
             return response()->json(['data' => "User doesn't exist", 'state' => false]);
         }
         $user = $collection->findOne(["email" => $email])->bsonSerialize();
         if (password_verify($password, $user->password) == false) {
             return response()->json(['data' => "Bad email or password", 'state' => false]);
         }
         $api = new Api($user);
         Auth::login($api);
         return response()->json(['data' => $user, 'state' => true]);
     } else {
         return response()->json(['data' => "Invalid parameters", 'state' => false]);
     }
     return response()->json(['data' => "Bad credentials", 'state' => false]);
 }
예제 #3
0
 /**
  * @param string $user_email
  *
  * @return HHPnet\Core\Domain\Users\User
  */
 public function getByEmail($user_email)
 {
     $user = $this->collection->findOne(['email' => $user_email]);
     return $this->getUserInstance($user);
 }
예제 #4
0
 /**
  * @param HHPnet\Core\Domain\Albums\AlbumId $song_id
  * @param string                            $name
  *
  * @return HHPnet\Core\Domain\Songs\Song
  */
 public function getBySongByName(AlbumId $album_id, $name)
 {
     $song = $this->collection->findOne(['album_id' => $album_id, 'name' => $name]);
     return $this->getSongInstance($song);
 }
예제 #5
0
 /**
  * @param string $video_service_id
  * @param string $video_service
  *
  * @return HHPnet\Core\Domain\Videos\Video
  */
 public function getByVideoServiceId($video_service_id, $video_service)
 {
     $video = $this->collection->findOne(['video_service_id' => $video_service_id, 'video_service' => $video_service]);
     return $this->getVideoInstance($video);
 }
예제 #6
0
 /**
  * @param string $name
  *
  * @return HHPnet\Core\Domain\Groups\Group
  */
 public function getByGroupByName($name)
 {
     $group = $this->collection->findOne(['name' => $name]);
     return $this->getGroupInstance($group);
 }
예제 #7
0
 /**
  * @param HHPnet\Core\Domain\Groups\GroupId $group_id
  * @param string                            $name
  *
  * @return HHPnet\Core\Domain\Albums\Album
  */
 public function getAlbumByName(GroupId $group_id, $name)
 {
     $album = $this->collection->findOne(['group_id' => $group_id, 'name' => $name]);
     return $this->getAlbumInstance($album);
 }