saved
This commit is contained in:
@ -1,22 +1,18 @@
|
||||
package co.jp.app.service;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import co.jp.app.entity.UserEntity;
|
||||
import co.jp.app.repository.userRepository;
|
||||
import co.jp.app.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
=======
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import co.jp.app.dto.RegistrationDto;
|
||||
import co.jp.app.entity.UserEntity;
|
||||
import co.jp.app.repository.UserRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
@ -24,34 +20,27 @@ import org.springframework.security.core.userdetails.User;
|
||||
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 co.jp.app.entity.PetEntity;
|
||||
import co.jp.app.repository.UploadRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
>>>>>>> 34de018ef0606dec4f6de48c8cc5c3f073a1fdc6
|
||||
|
||||
@Service
|
||||
public class UserService implements UserDetailsService {
|
||||
|
||||
<<<<<<< HEAD
|
||||
private final userRepository userEntityRepository;
|
||||
private final UserRepository userEntityRepository;
|
||||
|
||||
@Autowired
|
||||
public UserService(userRepository userEntityRepository, PasswordEncoder passwordEncoder )
|
||||
public UserService(UserRepository userEntityRepository, PasswordEncoder passwordEncoder )
|
||||
{
|
||||
this.userEntityRepository = userEntityRepository;
|
||||
this.passwordEncoder= passwordEncoder;
|
||||
|
||||
=======
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder) {
|
||||
this.userRepository = userRepository;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
>>>>>>> 34de018ef0606dec4f6de48c8cc5c3f073a1fdc6
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -75,16 +64,17 @@ public class UserService implements UserDetailsService {
|
||||
UserEntity userEntity = userRepository.findByEmail(email)
|
||||
.orElseThrow(() -> new UsernameNotFoundException(email + " not found"));
|
||||
|
||||
Collection<? extends GrantedAuthority> authorities = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")); // 示例:给所有用户一个ROLE_USER权限
|
||||
Collection<? extends GrantedAuthority> authorities = Collections
|
||||
.singletonList(new SimpleGrantedAuthority("ROLE_USER")); // 示例:给所有用户一个ROLE_USER权限
|
||||
|
||||
return new User(
|
||||
userEntity.getEmail(),
|
||||
userEntity.getPassword(),
|
||||
true, // enabled
|
||||
true, // accountNonExpired
|
||||
true, // credentialsNonExpired
|
||||
true, // accountNonLocked
|
||||
authorities // 用户的权限集合
|
||||
true, // enabled
|
||||
true, // accountNonExpired
|
||||
true, // credentialsNonExpired
|
||||
true, // accountNonLocked
|
||||
authorities // 用户的权限集合
|
||||
);
|
||||
}
|
||||
}
|
||||
|
2
target/classes/.gitignore
vendored
Normal file
2
target/classes/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/META-INF/
|
||||
/co/
|
@ -1,6 +1,6 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Mon May 12 14:19:16 JST 2025
|
||||
m2e.projectLocation=C\:\\Users\\ichbi\\OneDrive\\\u30C7\u30B9\u30AF\u30C8\u30C3\u30D7\\dog-1
|
||||
#Mon May 12 15:57:02 JST 2025
|
||||
m2e.projectLocation=C\:\\Users\\Administrator\\git\\Dog-1
|
||||
m2e.projectName=dog-1
|
||||
groupId=co.jp.app
|
||||
artifactId=dog-2
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user