Решенная ошибка c Bean, теперь пароли

This commit is contained in:
DyCTaTOR 2024-06-04 16:31:17 +04:00
parent b27e0717e5
commit dbff5ad51e
4 changed files with 22 additions and 2 deletions

View File

@ -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'

Binary file not shown.

View File

@ -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]

View File

@ -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);
}
}