Add Adminstration API to support accounts management #94

Merged
maxime.batista merged 6 commits from admin/api-accounts into master 1 year ago

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.

This pull request completes [PR #1](https://codefirst.iut.uca.fr/git/IQBall/Server-Panel/pulls/1) of our [Administration Application](https://codefirst.iut.uca.fr/git/IQBall/Server-Panel). # 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.
maxime.batista added 4 commits 1 year ago
maxime.batista requested review from clement.freville2 1 year ago
vivien.dufour requested changes 1 year ago
email
phoneNumber
passwordHash
Owner

it's not passwordHash and phoneNumber but password_hash and phone_number

it's not passwordHash and phoneNumber but password_hash and phone_number
maxime.batista marked this conversation as resolved
mael.daim requested changes 1 year ago
mael.daim left a comment
Owner
There is no content yet.
hash varchar NOT NULL,
profilePicture varchar NOT NULL
profile_picture varchar NOT NULL,
is_admin boolean DEFAULT false NOT NULL
Owner

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.

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.
maxime.batista marked this conversation as resolved
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
bfb216bfaf
fix suggestions
maxime.batista requested review from vivien.dufour 1 year ago
maxime.batista removed review request for vivien.dufour 1 year ago
maxime.batista requested review from mael.daim 1 year ago
maxime.batista requested review from vivien.dufour 1 year ago
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
954f82fa91
WIP
clement.freville2 requested changes 1 year ago
sql/database.php Outdated
}
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.

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.
maxime.batista marked this conversation as resolved
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 👀

So I may fetch one million users in a single request 👀
maxime.batista marked this conversation as resolved
* @param int $start starting index of the list content
* @return Account[]|null
*/
public function searchAccounts(int $start, int $n, ?string $searchString): ?array {
-     * @return Account[]|null
-     */
-    public function searchAccounts(int $start, int $n, ?string $searchString): ?array {
+     * @return Account[]
+     */
+    public function searchAccounts(int $start, int $n, ?string $searchString): array 
```diff - * @return Account[]|null - */ - public function searchAccounts(int $start, int $n, ?string $searchString): ?array { + * @return Account[] + */ + public function searchAccounts(int $start, int $n, ?string $searchString): array ```
maxime.batista marked this conversation as resolved
* @return TacticInfo[] | null
*/
public function listAllOf(int $user_id): ?array {
return$this->tactics->listAllOf($user_id);
-     * @return TacticInfo[] | null
-     */
-    public function listAllOf(int $user_id): ?array {
-        return$this->tactics->listAllOf($user_id);
+     * @return TacticInfo[]
+     */
+    public function listAllOf(int $user_id): array {
+        return $this->tactics->listAllOf($user_id);
```diff - * @return TacticInfo[] | null - */ - public function listAllOf(int $user_id): ?array { - return$this->tactics->listAllOf($user_id); + * @return TacticInfo[] + */ + public function listAllOf(int $user_id): array { + return $this->tactics->listAllOf($user_id); ```
maxime.batista marked this conversation as resolved
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.

-        return self::regex("/^-[0-9]+$/", "field is not an integer"); 
+        return self::regex("/^-?[0-9]+$/", "field is not an integer");
This only accepts negative numbers. ```diff - return self::regex("/^-[0-9]+$/", "field is not an integer"); + return self::regex("/^-?[0-9]+$/", "field is not an integer"); ```
maxime.batista marked this conversation as resolved
$idx = 0;
foreach ($val as $item) {
$failures = array_merge($failures, $this->validator->validate($name . "[$idx]", $item));
$idx += 1;
-                $idx = 0;
-                foreach ($val as $item) {
-                    $failures = array_merge($failures, $this->validator->validate($name . "[$idx]", $item));
-                    $idx += 1;
+                foreach ($val as $idx => $item) {
+                    $failures = array_merge($failures, $this->validator->validate("$name[$idx]", $item));
```diff - $idx = 0; - foreach ($val as $item) { - $failures = array_merge($failures, $this->validator->validate($name . "[$idx]", $item)); - $idx += 1; + foreach ($val as $idx => $item) { + $failures = array_merge($failures, $this->validator->validate("$name[$idx]", $item)); ```
maxime.batista marked this conversation as resolved
maxime.batista added 1 commit 1 year ago
continuous-integration/drone/push Build is failing Details
7536db9473
apply suggestions
maxime.batista force-pushed admin/api-accounts from 7536db9473 to 71bc95801b 1 year ago
maxime.batista force-pushed admin/api-accounts from 71bc95801b to 2ef68eacf1 1 year ago
maxime.batista merged commit a3e38bded1 into master 1 year ago
maxime.batista deleted branch admin/api-accounts 1 year ago

Reviewers

clement.freville2 was requested for review 1 year ago
mael.daim was requested for review 1 year ago
vivien.dufour was requested for review 1 year ago
continuous-integration/drone/push Build is passing
The pull request has been merged as a3e38bded1.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: IQBall/Application-Web#94
Loading…
There is no content yet.