[O] More checks

This commit is contained in:
Azalea
2024-02-19 02:29:45 -05:00
parent 7b89016359
commit 9c4f146778
2 changed files with 5 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ class UserRegistrar(
if (!email.isValidEmail()) 400 > "Invalid email"
// Check if user with the same email exists
if (async { userRepo.existsByEmail(email) }) 400 > "User already exists"
if (async { userRepo.existsByEmail(email) }) 400 > "User with email `$email` already exists"
// Check if username is valid
if (username.length < 2) 400 > "Username must be at least 2 letters"
@@ -47,6 +47,9 @@ class UserRegistrar(
"You can set a display name later."
}
// Check if user with the same username exists
if (async { userRepo.existsByUsername(username) }) 400 > "User with username `$username` already exists"
// Validate password
if (password.length < 8) 400 > "Password must be at least 8 characters"

View File

@@ -45,4 +45,5 @@ class AquaNetUser(
@Repository("AquaNetUserRepository")
interface AquaNetUserRepo : JpaRepository<AquaNetUser, Int> {
fun existsByEmail(email: String): Boolean
fun existsByUsername(username: String): Boolean
}