mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 22:50:51 +08:00
Return 404 when user or post not found
This commit is contained in:
@@ -104,14 +104,14 @@ public class UserService {
|
||||
|
||||
public User updateAvatar(String username, String avatarUrl) {
|
||||
User user = userRepository.findByUsername(username)
|
||||
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
||||
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));
|
||||
user.setAvatar(avatarUrl);
|
||||
return userRepository.save(user);
|
||||
}
|
||||
|
||||
public User updateProfile(String currentUsername, String newUsername, String introduction) {
|
||||
User user = userRepository.findByUsername(currentUsername)
|
||||
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
||||
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));
|
||||
if (newUsername != null && !newUsername.equals(currentUsername)) {
|
||||
usernameValidator.validate(newUsername);
|
||||
userRepository.findByUsername(newUsername).ifPresent(u -> {
|
||||
|
||||
Reference in New Issue
Block a user