mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-27 13:07:40 +08:00
feat: login logic
This commit is contained in:
@@ -50,9 +50,9 @@ export default {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': `Bearer ${this.token}`
|
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
token: this.token,
|
||||||
reason: this.reason
|
reason: this.reason
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class SecurityConfig {
|
|||||||
.requestMatchers(HttpMethod.GET, "/api/tags/**").permitAll()
|
.requestMatchers(HttpMethod.GET, "/api/tags/**").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, "/api/config/**").permitAll()
|
.requestMatchers(HttpMethod.GET, "/api/config/**").permitAll()
|
||||||
.requestMatchers(HttpMethod.POST,"/api/auth/google").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/search/**").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, "/api/users/**").permitAll()
|
.requestMatchers(HttpMethod.GET, "/api/users/**").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, "/api/reaction-types").permitAll()
|
.requestMatchers(HttpMethod.GET, "/api/reaction-types").permitAll()
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public class AuthController {
|
|||||||
return ResponseEntity.ok().body(Map.of("valid", true));
|
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());
|
notificationService.createRegisterRequestNotifications(user, req.getReason());
|
||||||
return ResponseEntity.ok().body(Map.of("valid", true));
|
return ResponseEntity.ok().body(Map.of("valid", true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,13 @@ public class UserService {
|
|||||||
return userRepository.save(user);
|
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) {
|
public User updateProfile(String currentUsername, String newUsername, String introduction) {
|
||||||
User user = userRepository.findByUsername(currentUsername)
|
User user = userRepository.findByUsername(currentUsername)
|
||||||
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));
|
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));
|
||||||
|
|||||||
Reference in New Issue
Block a user