#9 admin-password #10
BIN
data/db.mv.db
BIN
data/db.mv.db
Binary file not shown.
@ -2,6 +2,7 @@ package ru.ulstu.user;
|
|||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
@ -24,6 +25,8 @@ public class UserService implements UserDetailsService {
|
|||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final UserRoleRepository userRoleRepository;
|
private final UserRoleRepository userRoleRepository;
|
||||||
|
@Value("${admin-password}")
|
||||||
|
private String adminPassword;
|
||||||
|
|
||||||
public UserService(PasswordEncoder passwordEncoder,
|
public UserService(PasswordEncoder passwordEncoder,
|
||||||
UserRepository userRepository,
|
UserRepository userRepository,
|
||||||
@ -63,7 +66,6 @@ public class UserService implements UserDetailsService {
|
|||||||
|
|
||||||
public void initDefaultAdmin() {
|
public void initDefaultAdmin() {
|
||||||
String adminLogin = "admin";
|
String adminLogin = "admin";
|
||||||
String adminPassword = "adminadmin";
|
|
||||||
if (getUserByLogin(adminLogin) == null) {
|
if (getUserByLogin(adminLogin) == null) {
|
||||||
UserRole adminRole = userRoleRepository.save(new UserRole(UserRoleConstants.ADMIN));
|
UserRole adminRole = userRoleRepository.save(new UserRole(UserRoleConstants.ADMIN));
|
||||||
createUser(new User(adminLogin, adminPassword, Set.of(adminRole)));
|
createUser(new User(adminLogin, adminPassword, Set.of(adminRole)));
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
# You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
# You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
admin-password=admin
|
||||||
spring.main.banner-mode=off
|
spring.main.banner-mode=off
|
||||||
logging.level.tech.athene=DEBUG
|
logging.level.tech.athene=DEBUG
|
||||||
server.port=8080
|
server.port=8080
|
||||||
|
Loading…
Reference in New Issue
Block a user