Add Adminstration API to support accounts management #94
Merged
maxime.batista
merged 6 commits from admin/api-accounts
into master
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'admin/api-accounts'
Deleting a branch is permanent. It CANNOT be undone. Continue?
This pull request completes PR #1 of our Administration Application.
Current limitation
As said in the pull request, the application currently does not support Admin authentication, which is why the administration API (
/api/admin
is accessible for any non-authenticated request.email
phoneNumber
passwordHash
it's not passwordHash and phoneNumber but password_hash and phone_number
hash varchar NOT NULL,
profilePicture varchar NOT NULL
profile_picture varchar NOT NULL,
is_admin boolean DEFAULT false NOT NULL
Instead of adding a new attribute that will have the value false for almost every account. You should create a new table Admin referencing admin's account.
}
function init_database(PDO $pdo): void {
This is a fixture (initial/stub data for the database) that may not be written here because it may not be something that the user wants in production. Use a separate file.
public function listUsers(array $request): HttpResponse {
return APIControl::runCheckedFrom($request, [
'start' => [DefaultValidators::isUnsignedInteger()],
'n' => [DefaultValidators::isUnsignedInteger()],
So I may fetch one million users in a single request 👀
* @param int $start starting index of the list content
* @return Account[]|null
*/
public function searchAccounts(int $start, int $n, ?string $searchString): ?array {
* @return TacticInfo[] | null
*/
public function listAllOf(int $user_id): ?array {
return$this->tactics->listAllOf($user_id);
public static function isInteger(): Validator {
return self::regex("/^[0-9]+$/");
return self::regex("/^-[0-9]+$/", "field is not an integer");
This only accepts negative numbers.
$idx = 0;
foreach ($val as $item) {
$failures = array_merge($failures, $this->validator->validate($name . "[$idx]", $item));
$idx += 1;
7536db9473
to71bc95801b
1 year ago71bc95801b
to2ef68eacf1
1 year agoa3e38bded1
into master 1 year agoReviewers
a3e38bded1
.