mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-09 06:07:27 +08:00
[O] More checks
This commit is contained in:
@@ -34,7 +34,7 @@ class UserRegistrar(
|
|||||||
if (!email.isValidEmail()) 400 > "Invalid email"
|
if (!email.isValidEmail()) 400 > "Invalid email"
|
||||||
|
|
||||||
// Check if user with the same email exists
|
// 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
|
// Check if username is valid
|
||||||
if (username.length < 2) 400 > "Username must be at least 2 letters"
|
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."
|
"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
|
// Validate password
|
||||||
if (password.length < 8) 400 > "Password must be at least 8 characters"
|
if (password.length < 8) 400 > "Password must be at least 8 characters"
|
||||||
|
|
||||||
|
|||||||
@@ -45,4 +45,5 @@ class AquaNetUser(
|
|||||||
@Repository("AquaNetUserRepository")
|
@Repository("AquaNetUserRepository")
|
||||||
interface AquaNetUserRepo : JpaRepository<AquaNetUser, Int> {
|
interface AquaNetUserRepo : JpaRepository<AquaNetUser, Int> {
|
||||||
fun existsByEmail(email: String): Boolean
|
fun existsByEmail(email: String): Boolean
|
||||||
|
fun existsByUsername(username: String): Boolean
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user