diff --git a/src/migration/db.sql b/src/migration/db.sql index cea385cccb63b168ceba19a1c9a0364657620927..ca25431420d750039fe17223026c1a8c79b7a066 100644 --- a/src/migration/db.sql +++ b/src/migration/db.sql @@ -7,7 +7,7 @@ END $$; CREATE TABLE IF NOT EXISTS users ( - id VARCHAR(255) PRIMARY KEY, + id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, email VARCHAR(255) UNIQUE NOT NULL, @@ -15,8 +15,8 @@ CREATE TABLE IF NOT EXISTS users ( ); CREATE TABLE IF NOT EXISTS sessions ( - id VARCHAR(255) PRIMARY KEY, - user_id VARCHAR(255) NOT NULL, + id SERIAL PRIMARY KEY, + user_id INT NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ); diff --git a/src/server/app/Domain/User.php b/src/server/app/Domain/User.php index df35025a75a352922e655660b169ff9d77bc7608..9cb66796f78bd96c08ab551d26dc6bc11aab62f1 100644 --- a/src/server/app/Domain/User.php +++ b/src/server/app/Domain/User.php @@ -2,7 +2,7 @@ class User { - public string $id; + public int $id; public string $name; public string $password; public string $email; diff --git a/src/server/app/Model/UserRegisterRequest.php b/src/server/app/Model/UserRegisterRequest.php index 402b8af049f2c05b9afd4d5db8b71ea8f35032a9..e637486424a762c0ceb6153d94f678cddbf088bf 100644 --- a/src/server/app/Model/UserRegisterRequest.php +++ b/src/server/app/Model/UserRegisterRequest.php @@ -2,7 +2,10 @@ class UserRegisterRequest { - public ?string $id = null; + public ?int $id = null; public ?string $name = null; public ?string $password = null; -} + public ?string $confirm_password = null; + public ?string $email = null; + public ?string $role = null; +} \ No newline at end of file diff --git a/src/server/app/Repository/CatalogRepository.php b/src/server/app/Repository/CatalogRepository.php index 088f388055246b086f5573a304a59e09c8c73d67..5d738526dff84a3d7ffb500d939a02cb52e277f4 100644 --- a/src/server/app/Repository/CatalogRepository.php +++ b/src/server/app/Repository/CatalogRepository.php @@ -24,7 +24,7 @@ class CatalogRepository return $catalog; } - public function findById(string $id): ?Catalog + public function findById(int $id): ?Catalog { $statement = $this->connection->prepare("SELECT id, title, description, poster, trailer, category FROM catalogs WHERE id = ?"); $statement->execute([$id]); diff --git a/src/server/app/Repository/UserRepository.php b/src/server/app/Repository/UserRepository.php index 9223010936d07a9d2174f43b6acb1cf15b558199..057d41d5cc6caf99b9426a3526047fd498924ffb 100644 --- a/src/server/app/Repository/UserRepository.php +++ b/src/server/app/Repository/UserRepository.php @@ -24,7 +24,7 @@ class UserRepository return $user; } - public function findById(string $id): ?User + public function findById(int $id): ?User { $statement = $this->connection->prepare("SELECT id, name, password, email, role FROM users WHERE id = ?"); $statement->execute([$id]); diff --git a/src/server/app/Service/UserService.php b/src/server/app/Service/UserService.php index 3ee938219bfcd829263f660fd873ef363288c17f..e309e9c14a6e4c6c5ac0f3996cdf7127411aca8a 100644 --- a/src/server/app/Service/UserService.php +++ b/src/server/app/Service/UserService.php @@ -26,7 +26,6 @@ class UserService } $user = new User(); - $user->id = $request->id; $user->name = $request->name; $user->password = password_hash($request->password, PASSWORD_BCRYPT); @@ -46,11 +45,13 @@ class UserService private function validateUserRegistrationRequest(UserRegisterRequest $request) { - if ($request->id == null || $request->name == null | $request->password == null || - trim($request->id) == "" || trim($request->name) == "" || trim($request->password) == "") { + if ( + $request->name == null | $request->password == null || + trim($request->name) == "" || trim($request->password) == "" + ) { throw new ValidationException("Id, name, password cannot be blank"); } // more validations goes here } -} +} \ No newline at end of file