Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .devcontainer/backup.sh
Original file line number Diff line number Diff line change
@@ -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"
Empty file added .github/copilot-instructions.md
Empty file.
29 changes: 29 additions & 0 deletions error.json
Original file line number Diff line number Diff line change
@@ -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
]
}
]
}
2 changes: 2 additions & 0 deletions error.log
Original file line number Diff line number Diff line change
@@ -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.data.common.response.ApiResponseDataPojo<com.spacecodee.springbootsecurityopentemplate.data.common.auth.AuthenticationResponsePojo>> 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]] ]
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
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;

@Repository
public interface IRoleRepository extends JpaRepository<RoleEntity, Integer> {

@Query("select r from RoleEntity r where r.name = ?1")
Optional<RoleEntity> findByName(RoleEnum defaultRoleName);
@Query("select r from RoleEntity r where r.name = :defaultRoleName")
Optional<RoleEntity> 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<RoleEntity> findAdminRole(RoleEnum roleName);
@Query("select r from RoleEntity r where r.name = :roleName")
Optional<RoleEntity> findAdminRole(@Param("roleName") RoleEnum roleName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserEntity, Integer> {

@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<UserEntity> findByUsername(String username);

Expand Down