diff --git a/.devcontainer/backup.sh b/.devcontainer/backup.sh new file mode 100755 index 0000000..73c8775 --- /dev/null +++ b/.devcontainer/backup.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Define the backup file name and path +BACKUP_FILE="../src/main/resources/data/full_backup.sql" + +# Check if docker-compose.yml exists in the current directory +if [ ! -f docker-compose.yml ]; then + echo "docker-compose.yml not found in the current directory." + exit 1 +fi + +# Run the pg_dump command inside the db container with --inserts option +docker-compose exec db pg_dump --username=spacecodee --dbname=springboot_security_open_template --inserts > $BACKUP_FILE + +echo "Backup completed: $BACKUP_FILE" \ No newline at end of file diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..e69de29 diff --git a/error.json b/error.json new file mode 100644 index 0000000..2b43140 --- /dev/null +++ b/error.json @@ -0,0 +1,29 @@ +{ + "timestamp": "2024-12-15 05:45:16", + "backendMessage": "MethodArgumentNotValidException", + "message": "Validation error: 2", + "path": "/api/v1/auth/authenticate", + "method": "POST", + "data": [ + { + "field": "password", + "rejectedValue": "123", + "message": "Password must be between 6 and 32 characters", + "parameters": [ + "123", + 6, + 32 + ] + }, + { + "field": "username", + "rejectedValue": "a", + "message": "Username must be between 3 and 50 characters", + "parameters": [ + "a", + 3, + 50 + ] + } + ] + } \ No newline at end of file diff --git a/error.log b/error.log new file mode 100644 index 0000000..9161188 --- /dev/null +++ b/error.log @@ -0,0 +1,2 @@ +05:45:16.667 [http-nio-8080-exec-1] DEBUG c.s.s.language.MessageUtilComponent - Parameterized message resolved: 'Validation error: 2' +05:45:16.735 [http-nio-8080-exec-1] WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [1] in public org.springframework.http.ResponseEntity> com.spacecodee.springbootsecurityopentemplate.controller.api.auth.impl.AuthenticationControllerImpl.authenticate(java.lang.String,com.spacecodee.springbootsecurityopentemplate.data.vo.auth.LoginUserVO) with 2 errors: [Field error in object 'loginUserVO' on field 'password': rejected value [123]; codes [Size.loginUserVO.password,Size.password,Size.java.lang.String,Size]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [loginUserVO.password,password]; arguments []; default message [password],32,6]; default message [Password must be between {1} and {2} characters]] [Field error in object 'loginUserVO' on field 'username': rejected value [a]; codes [Size.loginUserVO.username,Size.username,Size.java.lang.String,Size]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [loginUserVO.username,username]; arguments []; default message [username],50,3]; default message [Username must be between {1} and {2} characters]] ] \ No newline at end of file diff --git a/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IRoleRepository.java b/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IRoleRepository.java index ae0beaf..eefa38c 100644 --- a/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IRoleRepository.java +++ b/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IRoleRepository.java @@ -4,6 +4,7 @@ import com.spacecodee.springbootsecurityopentemplate.persistence.entity.RoleEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.Optional; @@ -11,10 +12,10 @@ @Repository public interface IRoleRepository extends JpaRepository { - @Query("select r from RoleEntity r where r.name = ?1") - Optional findByName(RoleEnum defaultRoleName); + @Query("select r from RoleEntity r where r.name = :defaultRoleName") + Optional findByName(@Param("defaultRoleName") RoleEnum defaultRoleName); // get the admin role from properties located in resources/application.properties - @Query("select r from RoleEntity r where r.name = ?1") - Optional findAdminRole(RoleEnum roleName); + @Query("select r from RoleEntity r where r.name = :roleName") + Optional findAdminRole(@Param("roleName") RoleEnum roleName); } \ No newline at end of file diff --git a/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IUserRepository.java b/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IUserRepository.java index 6aeb6d3..b0e2500 100644 --- a/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IUserRepository.java +++ b/src/main/java/com/spacecodee/springbootsecurityopentemplate/persistence/repository/IUserRepository.java @@ -4,14 +4,15 @@ import com.spacecodee.springbootsecurityopentemplate.persistence.entity.UserEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; import java.util.Optional; public interface IUserRepository extends JpaRepository { - @Query("select count(u) from UserEntity u where u.roleEntity.name = ?1") - long countAdmins(RoleEnum name); + @Query("select count(u) from UserEntity u where u.roleEntity.name = :name") + long countAdmins(@Param("name") RoleEnum name); Optional findByUsername(String username);