mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-05 05:27:30 +08:00
[O] More checks
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -45,4 +45,5 @@ class AquaNetUser(
|
||||
@Repository("AquaNetUserRepository")
|
||||
interface AquaNetUserRepo : JpaRepository<AquaNetUser, Int> {
|
||||
fun existsByEmail(email: String): Boolean
|
||||
fun existsByUsername(username: String): Boolean
|
||||
}
|
||||
Reference in New Issue
Block a user