Merge pull request '#9 admin-password' (#10) from 9-admin-password into master

Reviewed-on: #10
This commit is contained in:
romanov73 2022-03-18 11:39:58 +04:00
commit 0f500266bc
3 changed files with 4 additions and 1 deletions

Binary file not shown.

View File

@ -2,6 +2,7 @@ package ru.ulstu.user;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
@ -24,6 +25,8 @@ public class UserService implements UserDetailsService {
private final PasswordEncoder passwordEncoder;
private final UserRepository userRepository;
private final UserRoleRepository userRoleRepository;
@Value("${admin-password}")
private String adminPassword;
public UserService(PasswordEncoder passwordEncoder,
UserRepository userRepository,
@ -63,7 +66,6 @@ public class UserService implements UserDetailsService {
public void initDefaultAdmin() {
String adminLogin = "admin";
String adminPassword = "adminadmin";
if (getUserByLogin(adminLogin) == null) {
UserRole adminRole = userRoleRepository.save(new UserRole(UserRoleConstants.ADMIN));
createUser(new User(adminLogin, adminPassword, Set.of(adminRole)));

View File

@ -3,6 +3,7 @@
# You may use, distribute and modify this code, please write to: romanov73@gmail.com.
#
#
admin-password=admin
spring.main.banner-mode=off
logging.level.tech.athene=DEBUG
server.port=8080