修正版本

This commit is contained in:
2025-05-12 16:02:18 +09:00
parent b23ba3b92a
commit 38e91f45b6

View File

@ -33,7 +33,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();
@ -50,7 +50,7 @@ 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"));
return new User(
userEntity.getEmail(),
@ -59,7 +59,7 @@ public class UserService implements UserDetailsService {
true, // accountNonExpired
true, // credentialsNonExpired
true, // accountNonLocked
authorities // 用户的权限集合
authorities // role
);
}
}