public function getAll($startIndex = 0, $search = null) { $condition = new Condition(); $condition->in('status', [Table\Rate::STATUS_ACTIVE]); if (!empty($search)) { $condition->like('name', '%' . $search . '%'); } return new ResultSet($this->rateTable->getCount($condition), $startIndex, 16, $this->rateTable->getAll($startIndex, 16, 'priority', Sql::SORT_DESC, $condition)); }
public function getAll($startIndex = 0, $search = null) { $condition = new Condition(); $condition->in('status', [Table\App::STATUS_ACTIVE, Table\App::STATUS_PENDING]); if (!empty($search)) { $condition->like('name', '%' . $search . '%'); } return new ResultSet($this->appTable->getCount($condition), $startIndex, 16, $this->appTable->getAll($startIndex, 16, 'id', Sql::SORT_DESC, $condition, Fields::blacklist(['url', 'parameters', 'appSecret']))); }
public function create($userId, $name, $url, array $scopes = null) { // validate data $this->assertName($name); $this->assertUrl($url); // check limit of apps which an user can create $condition = new Condition(); $condition->equals('userId', $userId); $condition->in('status', [Table\App::STATUS_ACTIVE, Table\App::STATUS_PENDING, Table\App::STATUS_DEACTIVATED]); if ($this->appTable->getCount($condition) > $this->appCount) { throw new StatusCode\BadRequestException('Maximal amount of apps reached. Please delete another app in order to register a new one'); } $scopes = $this->getValidUserScopes($userId, $scopes); if (empty($scopes)) { throw new StatusCode\BadRequestException('Provide at least one valid scope for the app'); } $this->appService->create($userId, $this->appApproval === false ? Table\App::STATUS_ACTIVE : Table\App::STATUS_PENDING, $name, $url, null, $scopes); }
/** * Authenticates a user based on the username and password. Returns the user * id if the authentication was successful else null * * @param string $username * @param string $password * @param array $status * @return integer|null */ public function authenticateUser($username, $password, array $status) { if (empty($password)) { return null; } $condition = new Condition(); $condition->equals('name', $username); $condition->in('status', $status); $user = $this->userTable->getOneBy($condition); if (!empty($user)) { // we can authenticate only local users if ($user->provider != ProviderInterface::PROVIDER_SYSTEM) { return null; } if ($user->status == Table\User::STATUS_DISABLED) { throw new StatusCode\BadRequestException('The assigned account is disabled'); } if ($user->status == Table\User::STATUS_DELETED) { throw new StatusCode\BadRequestException('The assigned account is deleted'); } // check password if (password_verify($password, $user['password'])) { return $user['id']; } } return null; }