feat: login logic

This commit is contained in:
Tim
2025-07-16 12:54:10 +08:00
parent ea85af4a52
commit e42b5db5a0
4 changed files with 10 additions and 2 deletions

View File

@@ -102,6 +102,7 @@ public class SecurityConfig {
.requestMatchers(HttpMethod.GET, "/api/tags/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/config/**").permitAll()
.requestMatchers(HttpMethod.POST,"/api/auth/google").permitAll()
.requestMatchers(HttpMethod.POST,"/api/auth/reason").permitAll()
.requestMatchers(HttpMethod.GET, "/api/search/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/users/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/reaction-types").permitAll()

View File

@@ -153,7 +153,7 @@ public class AuthController {
return ResponseEntity.ok().body(Map.of("valid", true));
}
userService.register(user.getUsername(), user.getEmail(), user.getPassword(), req.getReason(), registerModeService.getRegisterMode());
user = userService.updateReason(user.getUsername(), req.getReason());
notificationService.createRegisterRequestNotifications(user, req.getReason());
return ResponseEntity.ok().body(Map.of("valid", true));
}

View File

@@ -124,6 +124,13 @@ public class UserService {
return userRepository.save(user);
}
public User updateReason(String username, String reason) {
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));
user.setRegisterReason(reason);
return userRepository.save(user);
}
public User updateProfile(String currentUsername, String newUsername, String introduction) {
User user = userRepository.findByUsername(currentUsername)
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));