feat: Add prefecture modification support (#170)

This commit is contained in:
alexay7
2025-08-21 22:19:25 +02:00
committed by GitHub
parent 15412911a9
commit 3d95a84739
21 changed files with 294 additions and 24 deletions

View File

@@ -161,7 +161,7 @@ class UserRegistrar(
// Check if user exists, treat as email / username
val user = async { userRepo.findByEmailIgnoreCase(email) ?: userRepo.findByUsernameIgnoreCase(email) }
?: return SUCCESS // obviously dont tell them if the email exists or not
// Check if email is verified
if (!user.emailConfirmed && emailProps.enable) 400 - "Email not verified"
@@ -179,7 +179,7 @@ class UserRegistrar(
// Send a password reset email
emailService.sendPasswordReset(user)
return SUCCESS
}
@@ -189,7 +189,7 @@ class UserRegistrar(
@RP token: Str, @RP password: Str,
request: HttpServletRequest
) : Any {
// Find the reset token
val reset = async { resetPasswordRepo.findByToken(token) }
@@ -302,4 +302,17 @@ class UserRegistrar(
SUCCESS
}
@API("/change-region")
@Doc("Change the region of the user.", "Success message")
suspend fun changeRegion(@RP token: Str, @RP regionId: Str) = jwt.auth(token) { u ->
// Check if the region is valid (between 1 and 47)
val r = regionId.toIntOrNull() ?: (400 - "Invalid region")
if (r !in 1..47) 400 - "Invalid region"
async {
userRepo.save(u.apply { region = r.toString() })
}
SUCCESS
}
}