diff --git a/build.gradle b/build.gradle index b37dbc4..114ed19 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,6 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' implementation 'org.modelmapper:modelmapper:3.2.0' developmentOnly 'org.springframework.boot:spring-boot-devtools' diff --git a/data.mv.db b/data.mv.db index 4abc35d..2b02968 100644 Binary files a/data.mv.db and b/data.mv.db differ diff --git a/data.trace.db b/data.trace.db index 65e364f..3873d23 100644 --- a/data.trace.db +++ b/data.trace.db @@ -29734,3 +29734,7 @@ Column "KEY_SEQ" not found [42122-224] at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148) at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) +2024-06-04 16:30:33.469322+04:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(25)": "'$2a$10$66PWaq98dEAxag2OS2RZ9ex.xe6a0Jd9zWiFoDQffg4TOukWp77bq' (60)" +Value too long for column "PASSWORD CHARACTER VARYING(25)": "'$2a$10$66PWaq98dEAxag2OS2RZ9ex.xe6a0Jd9zWiFoDQffg4TOukWp77bq' (60)"; SQL statement: +insert into entrys_data (department_id,login,password,role,id) values (?,?,?,?,?) [22001-224] diff --git a/src/main/java/com/example/demo/entrysData/service/EntrysDataService.java b/src/main/java/com/example/demo/entrysData/service/EntrysDataService.java index 8699693..14b9aa3 100644 --- a/src/main/java/com/example/demo/entrysData/service/EntrysDataService.java +++ b/src/main/java/com/example/demo/entrysData/service/EntrysDataService.java @@ -7,6 +7,9 @@ import java.util.stream.StreamSupport; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -14,6 +17,7 @@ import org.springframework.util.StringUtils; import com.example.demo.core.configuration.Constants; import com.example.demo.core.error.NotFoundException; +import com.example.demo.core.security.UserPrincipal; import com.example.demo.entrysData.model.EntrysDataEntity; import com.example.demo.entrysData.model.EntrysDataGrouped; import com.example.demo.entrysData.model.EntrysDataGroupedDepartment; @@ -21,7 +25,7 @@ import com.example.demo.entrysData.model.EntrysDataRole; import com.example.demo.entrysData.repository.EntrysDataRepository; @Service -public class EntrysDataService { +public class EntrysDataService implements UserDetailsService{ private final EntrysDataRepository repository; private final PasswordEncoder passwordEncoder; @@ -104,4 +108,17 @@ public class EntrysDataService { final Pageable pageRequest = PageRequest.of(page, size); return repository.findAllWithDepartment(pageRequest); } + + @Transactional(readOnly = true) + public EntrysDataEntity getByLogin(String login) { + return repository.findByloginIgnoreCase(login) + .orElseThrow(() -> new IllegalArgumentException("Invalid login")); + } + + @Override + @Transactional(readOnly = true) + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + final EntrysDataEntity existsUser = getByLogin(username); + return new UserPrincipal(existsUser); + } }