6161
6262
6363def validate_password_strength_and_match (
64- password : str = Form (...),
65- confirm_password : str = Form (...)
64+ password : str = Form (..., title = "Password" , description = "Account password" ),
65+ confirm_password : str = Form (..., title = "Confirm password" , description = "Re-enter password to confirm" )
6666) -> str :
6767 """
6868 Validates password strength and confirms passwords match.
@@ -120,9 +120,9 @@ async def read_login(
120120 if user :
121121 return RedirectResponse (url = dashboard_router .url_path_for ("read_dashboard" ), status_code = 302 )
122122 return templates .TemplateResponse (
123+ request ,
123124 "account/login.html" ,
124125 {
125- "request" : request ,
126126 "user" : user ,
127127 "invitation_token" : invitation_token
128128 }
@@ -143,9 +143,9 @@ async def read_register(
143143 return RedirectResponse (url = dashboard_router .url_path_for ("read_dashboard" ), status_code = 302 )
144144
145145 return templates .TemplateResponse (
146+ request ,
146147 "account/register.html" ,
147148 {
148- "request" : request ,
149149 "user" : user ,
150150 "password_pattern" : HTML_PASSWORD_PATTERN ,
151151 "email" : email ,
@@ -167,8 +167,9 @@ async def read_forgot_password(
167167 return RedirectResponse (url = dashboard_router .url_path_for ("read_dashboard" ), status_code = 302 )
168168
169169 return templates .TemplateResponse (
170+ request ,
170171 "account/forgot_password.html" ,
171- {"request" : request , " user" : user , "show_form" : show_form == "true" }
172+ {"user" : user , "show_form" : show_form == "true" }
172173 )
173174
174175
@@ -190,15 +191,16 @@ async def read_reset_password(
190191 raise CredentialsError (message = "Invalid or expired token" )
191192
192193 return templates .TemplateResponse (
194+ request ,
193195 "account/reset_password.html" ,
194- {"request" : request , " user" : user , "email" : email , "token" : token , "password_pattern" : HTML_PASSWORD_PATTERN }
196+ {"user" : user , "email" : email , "token" : token , "password_pattern" : HTML_PASSWORD_PATTERN }
195197 )
196198
197199
198200@router .post ("/delete" , response_class = RedirectResponse )
199201async def delete_account (
200- email : EmailStr = Form (...),
201- password : str = Form (...),
202+ email : EmailStr = Form (..., title = "Email" , description = "Account email address for verification" ),
203+ password : str = Form (..., title = "Password" , description = "Account password for verification" ),
202204 account : Account = Depends (get_authenticated_account ),
203205 session : Session = Depends (get_session )
204206):
@@ -229,12 +231,12 @@ async def delete_account(
229231async def register (
230232 request : Request ,
231233 _ip_check : None = Depends (check_register_ip_rate_limit ),
232- name : str = Form (...),
233- email : EmailStr = Form (...),
234+ name : str = Form (..., min_length = 1 , strip_whitespace = True , title = "Name" , description = "Your full name" ),
235+ email : EmailStr = Form (..., title = "Email" , description = "Email address for the new account" ),
234236 session : Session = Depends (get_session ),
235237 _ : None = Depends (validate_password_strength_and_match ),
236- password : str = Form (...),
237- invitation_token : Optional [str ] = Form (None )
238+ password : str = Form (..., title = "Password" , description = "Account password" ),
239+ invitation_token : Optional [str ] = Form (None , title = "Invitation token" , description = "Optional invitation token to join an organization" )
238240) -> Response :
239241 """
240242 Register a new user account, optionally processing an invitation.
@@ -353,7 +355,7 @@ async def login(
353355 _ip_check : None = Depends (check_login_ip_rate_limit ),
354356 _email_check : EmailStr = Depends (check_login_email_rate_limit ),
355357 account_and_session : Tuple [Account , Session ] = Depends (get_account_from_credentials ),
356- invitation_token : Optional [str ] = Form (None )
358+ invitation_token : Optional [str ] = Form (None , title = "Invitation token" , description = "Optional invitation token to join an organization after login" )
357359) -> Response :
358360 """
359361 Log in a user with valid credentials and process invitation if token is provided.
@@ -534,8 +536,8 @@ async def forgot_password(
534536@router .post ("/reset_password" )
535537async def reset_password (
536538 request : Request ,
537- email : EmailStr = Form (...),
538- token : str = Form (...),
539+ email : EmailStr = Form (..., title = "Email" , description = "Account email address" ),
540+ token : str = Form (..., title = "Reset token" , description = "Password reset token from email" ),
539541 new_password : str = Depends (validate_password_strength_and_match ),
540542 session : Session = Depends (get_session )
541543):
@@ -569,8 +571,8 @@ async def reset_password(
569571@router .post ("/update_email" )
570572async def request_email_update (
571573 request : Request ,
572- email : EmailStr = Form (...),
573- new_email : EmailStr = Form (...),
574+ email : EmailStr = Form (..., title = "Current email" , description = "Current account email address" ),
575+ new_email : EmailStr = Form (..., title = "New email" , description = "New email address to update to" ),
574576 account : Account = Depends (get_authenticated_account ),
575577 session : Session = Depends (get_session )
576578):
0 commit comments