Skip to content

Commit 06cdcc2

Browse files
committed
feat(frontend): force email adress to signup
1 parent 45236be commit 06cdcc2

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

backend/app/api/endpoints/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def sign_up(user: UserCreate, db: Session = Depends(get_db)):
1616
if db.query(User).filter(User.username == user.username).first():
1717
raise HTTPException(
1818
status_code=status.HTTP_400_BAD_REQUEST,
19-
detail="Username already registered"
19+
detail="Email already registered"
2020
)
2121

2222
if "@" not in user.username or "." not in user.username.split("@")[-1]:
2323
raise HTTPException(
2424
status_code=status.HTTP_400_BAD_REQUEST,
25-
detail="Username must be a valid email address"
25+
detail="Email must be a valid email address"
2626
)
2727

2828
# Crée le nouvel utilisateur

backend/app/tests/api/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_sign_up_duplicate_username(client: TestClient, test_user):
2626
}
2727
)
2828
assert response.status_code == 400
29-
assert "Username already registered" in response.json()["detail"]
29+
assert "Email already registered" in response.json()["detail"]
3030

3131
def test_sign_in_success(client: TestClient, test_user):
3232
response = client.post(

frontend/src/components/LoginForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ export default function LoginForm() {
2626
<form onSubmit={handleSubmit(onSubmit)} className="space-y-6">
2727
<div>
2828
<label htmlFor="username" className="block text-sm font-medium text-gray-700">
29-
Username
29+
Email address
3030
</label>
3131
<input
32-
{...register('username', { required: 'Username is required' })}
32+
{...register('username', {
33+
required: 'Email address is required',
34+
})}
3335
type="text"
3436
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500"
3537
/>

frontend/src/components/SignUpForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export default function SignUpForm() {
4444
<form onSubmit={handleSubmit(onSubmit)} className="space-y-6" method="POST">
4545
<div>
4646
<label htmlFor="username" className="block text-sm font-medium text-gray-700">
47-
Username
47+
Email
4848
</label>
4949
<input
50-
{...register('username', { required: 'Username is required' })}
51-
type="text"
50+
{...register('username', { required: 'Email address is required' })}
51+
type="email"
5252
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500"
5353
disabled={success}
5454
/>

0 commit comments

Comments
 (0)