From bffe28ac295258e8503b920786befedb984134fd Mon Sep 17 00:00:00 2001 From: Tofik Sahraoui Date: Sat, 15 Jun 2024 17:49:36 +0200 Subject: [PATCH] flyway stuff --- .../controller/AuthenticationController.java | 8 ++++++-- src/main/java/no/josefushighscore/dto/UserDto.java | 2 +- src/main/resources/application.yml | 3 +-- .../{V0_0_1__user.sql => V0_0_1__create_table_user.sql} | 2 -- ...user_roles.sql => V0_0_2__create_table_user_roles.sql} | 0 .../{V0_0_3__score.sql => V0_0_3__create_table_score.sql} | 0 .../{V0_0_4__game.sql => V0_0_4__create_table_game.sql} | 0 ...ed_on_column.sql => V0_1_1__alter_table_user_role.sql} | 0 8 files changed, 8 insertions(+), 7 deletions(-) rename src/main/resources/db.migration/{V0_0_1__user.sql => V0_0_1__create_table_user.sql} (85%) rename src/main/resources/db.migration/{V0_0_2__user_roles.sql => V0_0_2__create_table_user_roles.sql} (100%) rename src/main/resources/db.migration/{V0_0_3__score.sql => V0_0_3__create_table_score.sql} (100%) rename src/main/resources/db.migration/{V0_0_4__game.sql => V0_0_4__create_table_game.sql} (100%) rename src/main/resources/db.migration/{V0_1_1__created_on_column.sql => V0_1_1__alter_table_user_role.sql} (100%) diff --git a/src/main/java/no/josefushighscore/controller/AuthenticationController.java b/src/main/java/no/josefushighscore/controller/AuthenticationController.java index c950e24..6a2eb5f 100644 --- a/src/main/java/no/josefushighscore/controller/AuthenticationController.java +++ b/src/main/java/no/josefushighscore/controller/AuthenticationController.java @@ -1,11 +1,12 @@ package no.josefushighscore.controller; -import jakarta.validation.Valid; import no.josefushighscore.dto.LoginUserDto; import no.josefushighscore.dto.UserDto; import no.josefushighscore.exception.BadRequestException; import no.josefushighscore.service.APIResponse; import no.josefushighscore.service.UserLoginService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -23,6 +24,8 @@ public class AuthenticationController { @Autowired UserLoginService loginService; + Logger LOG = LoggerFactory.getLogger(AuthenticationController.class); + @Secured("ROLE_ANONYMOUS") @PostMapping("/signin") public ResponseEntity signin(@RequestBody LoginUserDto data) throws AuthenticationException { @@ -35,9 +38,10 @@ public ResponseEntity signin(@RequestBody LoginUserDto data) throw @Secured("ROLE_ANONYMOUS") @PostMapping("/register") - public ResponseEntity registerNewUserAccount(@Valid @RequestBody UserDto accountDto) throws BadRequestException { + public ResponseEntity registerNewUserAccount(@RequestBody UserDto accountDto) throws BadRequestException { APIResponse apiResponse = new APIResponse(); + LOG.info(String.valueOf(accountDto)); loginService.registerNewUserAccount(accountDto); apiResponse.setStatus(HttpStatus.CREATED); apiResponse.setMessage("User registered successfully"); diff --git a/src/main/java/no/josefushighscore/dto/UserDto.java b/src/main/java/no/josefushighscore/dto/UserDto.java index 09c3b91..a0ee103 100644 --- a/src/main/java/no/josefushighscore/dto/UserDto.java +++ b/src/main/java/no/josefushighscore/dto/UserDto.java @@ -10,7 +10,7 @@ public class UserDto { @JsonProperty("username") private String username; - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty("password") private String password; @JsonProperty("firstname") diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8d9163b..a235dc1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,12 +20,11 @@ spring: default-property-inclusion: non_empty flyway: url: ${spring.datasource.url} + schemas: josefushighscore enabled: true locations: classpath:/db/migration user: ${SUPABASE_JOSEFUS_DB_USER} password: ${SUPABASE_JOSEFUS_DB_PWD} - baseline-on-migrate: true - baseline-version: '0' jwt: secret: ${JOSEFUS_JWT_SECRET} diff --git a/src/main/resources/db.migration/V0_0_1__user.sql b/src/main/resources/db.migration/V0_0_1__create_table_user.sql similarity index 85% rename from src/main/resources/db.migration/V0_0_1__user.sql rename to src/main/resources/db.migration/V0_0_1__create_table_user.sql index a0a89ed..843a975 100644 --- a/src/main/resources/db.migration/V0_0_1__user.sql +++ b/src/main/resources/db.migration/V0_0_1__create_table_user.sql @@ -1,5 +1,3 @@ -CREATE SCHEMA IF NOT EXISTS josefus; - CREATE TABLE IF NOT EXISTS USER ( user_id bigint NOT NULL, email varchar(255), diff --git a/src/main/resources/db.migration/V0_0_2__user_roles.sql b/src/main/resources/db.migration/V0_0_2__create_table_user_roles.sql similarity index 100% rename from src/main/resources/db.migration/V0_0_2__user_roles.sql rename to src/main/resources/db.migration/V0_0_2__create_table_user_roles.sql diff --git a/src/main/resources/db.migration/V0_0_3__score.sql b/src/main/resources/db.migration/V0_0_3__create_table_score.sql similarity index 100% rename from src/main/resources/db.migration/V0_0_3__score.sql rename to src/main/resources/db.migration/V0_0_3__create_table_score.sql diff --git a/src/main/resources/db.migration/V0_0_4__game.sql b/src/main/resources/db.migration/V0_0_4__create_table_game.sql similarity index 100% rename from src/main/resources/db.migration/V0_0_4__game.sql rename to src/main/resources/db.migration/V0_0_4__create_table_game.sql diff --git a/src/main/resources/db.migration/V0_1_1__created_on_column.sql b/src/main/resources/db.migration/V0_1_1__alter_table_user_role.sql similarity index 100% rename from src/main/resources/db.migration/V0_1_1__created_on_column.sql rename to src/main/resources/db.migration/V0_1_1__alter_table_user_role.sql