mirror of
https://github.com/EDeev/compile-hub.git
synced 2026-06-15 11:01:11 +03:00
check username
This commit is contained in:
parent
cae5b987d4
commit
822c43f609
1 changed files with 15 additions and 0 deletions
15
main.py
15
main.py
|
|
@ -144,6 +144,21 @@ async def register(user: UserRegister):
|
||||||
|
|
||||||
return {"message": "Successfully signed up, please login", "success": True}
|
return {"message": "Successfully signed up, please login", "success": True}
|
||||||
|
|
||||||
|
@app.get("/api/auth/check-username")
|
||||||
|
async def check_username_availability(username: str):
|
||||||
|
if not username or len(username.strip()) == 0:
|
||||||
|
raise HTTPException(400, "Username cannot be empty")
|
||||||
|
|
||||||
|
if len(username) < 3 or len(username) > 20:
|
||||||
|
raise HTTPException(400, "Username must be between 3 and 20 characters")
|
||||||
|
|
||||||
|
existing_user = db.get_user_by_username(username.strip())
|
||||||
|
|
||||||
|
return {
|
||||||
|
"available": existing_user is None,
|
||||||
|
"username": username.strip()
|
||||||
|
}
|
||||||
|
|
||||||
@app.post("/api/auth/login")
|
@app.post("/api/auth/login")
|
||||||
async def login(user: UserLogin):
|
async def login(user: UserLogin):
|
||||||
db_user = db.get_user_by_username(user.username)
|
db_user = db.get_user_by_username(user.username)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue