sss
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -8,9 +9,10 @@ import co.jp.app.entity.UserEntity;
|
||||
import co.jp.app.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
=======
|
||||
>>>>>>> 38e91f45b6838b27b12a3262ceb60f6a03a0fd2e
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import co.jp.app.dto.RegistrationDto;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -21,12 +23,17 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import co.jp.app.entity.PetEntity;
|
||||
import co.jp.app.repository.UploadRepository;
|
||||
=======
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
>>>>>>> 38e91f45b6838b27b12a3262ceb60f6a03a0fd2e
|
||||
|
||||
@Service
|
||||
public class UserService implements UserDetailsService {
|
||||
|
||||
<<<<<<< HEAD
|
||||
private final UserRepository userEntityRepository;
|
||||
|
||||
@Autowired
|
||||
@ -35,6 +42,8 @@ public class UserService implements UserDetailsService {
|
||||
this.userEntityRepository = userEntityRepository;
|
||||
this.passwordEncoder= passwordEncoder;
|
||||
|
||||
=======
|
||||
>>>>>>> 38e91f45b6838b27b12a3262ceb60f6a03a0fd2e
|
||||
private final UserRepository userRepository;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
@ -47,7 +56,7 @@ public class UserService implements UserDetailsService {
|
||||
public UserEntity registerNewUser(@NotNull RegistrationDto registrationDto) throws Exception {
|
||||
|
||||
if (userRepository.existsByEmail(registrationDto.getEmail())) {
|
||||
throw new Exception("エラー:メール:" + registrationDto.getEmail() + " はすでに登録されました。");
|
||||
throw new Exception("error: Email" + registrationDto.getEmail() + " had been used");
|
||||
}
|
||||
|
||||
UserEntity newUser = new UserEntity();
|
||||
@ -64,17 +73,29 @@ public class UserService implements UserDetailsService {
|
||||
UserEntity userEntity = userRepository.findByEmail(email)
|
||||
.orElseThrow(() -> new UsernameNotFoundException(email + " not found"));
|
||||
|
||||
<<<<<<< HEAD
|
||||
Collection<? extends GrantedAuthority> authorities = Collections
|
||||
.singletonList(new SimpleGrantedAuthority("ROLE_USER")); // 示例:给所有用户一个ROLE_USER权限
|
||||
=======
|
||||
Collection<? extends GrantedAuthority> authorities = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
|
||||
>>>>>>> 38e91f45b6838b27b12a3262ceb60f6a03a0fd2e
|
||||
|
||||
return new User(
|
||||
userEntity.getEmail(),
|
||||
userEntity.getPassword(),
|
||||
<<<<<<< HEAD
|
||||
true, // enabled
|
||||
true, // accountNonExpired
|
||||
true, // credentialsNonExpired
|
||||
true, // accountNonLocked
|
||||
authorities // 用户的权限集合
|
||||
=======
|
||||
true, // enabled
|
||||
true, // accountNonExpired
|
||||
true, // credentialsNonExpired
|
||||
true, // accountNonLocked
|
||||
authorities // role
|
||||
>>>>>>> 38e91f45b6838b27b12a3262ceb60f6a03a0fd2e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user