Users API reference
Users
User management router for authenticated operations.
approve_user
approve_user(request, user_id, db)
Approve pending user account.
A user who is not awaiting approval, is deactivated or is queued for deletion, or whose email is not verified while sign-up requires verification, is refused with 409.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_id
|
UuidId
|
ID of user to approve. |
required |
db
|
DbSession
|
Database session dependency. |
required |
Source code in backend/app/modules/users/users/router.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
create_user
create_user(request, user, token_user_id, token_session_id, step_up_store, db, response)
Create a new user (admin operation).
An administrator account needs the creating administrator's own step-up verification in step_up (their
current password or, for an account without one, a fresh identity-provider sign-in, and an MFA code when MFA
is enabled). A regular account needs no step_up.
The password is optional when the server has mail configured: without it the account is created active with
no password and its owner is emailed a link, valid for 24 hours, to choose one. Without mail, or for an inactive
account, a missing password is refused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user
|
UserAdminCreate
|
User creation data, and the administrator's step-up. |
required |
token_user_id
|
CurrentUserId
|
ID of the administrator creating the user. |
required |
token_session_id
|
CurrentSessionId
|
Session ID of the administrator. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, whose |
required |
Returns:
| Type | Description |
|---|---|
UserRead
|
Created user data. |
Source code in backend/app/modules/users/users/router.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
delete_user
delete_user(request, response, user_id, body, token_user_id, token_session_id, step_up_store, states, storage, mail, if_match, db)
Queue the deletion of another user's account.
Requires the administrator's own step-up verification: their current password (or, for an account
without one, a fresh identity-provider sign-in), and an MFA code when MFA is enabled. The user is signed
out and deactivated at once and a background job erases their data. Poll GET /jobs/{job_id} for the
outcome; a failed deletion is requested again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which names the job and when to poll it. |
required |
user_id
|
UuidId
|
ID of user to delete. |
required |
body
|
StepUpRequest
|
The administrator's step-up verification. |
required |
token_user_id
|
CurrentUserId
|
ID of the administrator making the request. |
required |
token_session_id
|
CurrentSessionId
|
Session ID of the administrator. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
states
|
UserDeletionStateStoreDep
|
Shared store of the deletion's state. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
mail
|
Mail
|
The platform mail provider. |
required |
if_match
|
IfMatch
|
The |
required |
db
|
DbSession
|
Database session dependency. |
required |
Returns:
| Type | Description |
|---|---|
UserDeletionStatus
|
The deletion's initial status, with the id of the job that reads it. |
Raises:
| Type | Description |
|---|---|
PermissionDeniedError
|
If the administrator targets their own account. |
NotFoundError
|
If the user does not exist. |
PreconditionFailedError
|
If the user changed since the client read it. |
LastAdministratorError
|
If the user is the only administrator. |
JobAlreadyRunningError
|
If a deletion is already pending. |
Source code in backend/app/modules/users/users/router.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
delete_user_identity_provider
delete_user_identity_provider(request, user_id, idp_id, body, token_user_id, token_session_id, step_up_store, db)
Unlink an identity provider from another user (admin).
Requires the administrator's own step-up verification: their current password (or, for an account without one, a fresh identity-provider sign-in), and an MFA code when MFA is enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_id
|
UuidId
|
ID of the user to unlink the identity provider from. |
required |
idp_id
|
UuidId
|
ID of the identity provider to unlink. |
required |
body
|
StepUpRequest
|
The administrator's step-up verification. |
required |
token_user_id
|
CurrentUserId
|
ID of the administrator making the change. |
required |
token_session_id
|
CurrentSessionId
|
Session ID of the administrator. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
db
|
DbSession
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in backend/app/modules/users/users/router.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
delete_user_photo
delete_user_photo(request, user_id, storage, db)
Delete user profile photo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_id
|
UuidId
|
ID of user whose photo to delete. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
db
|
DbSession
|
Database session dependency. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in backend/app/modules/users/users/router.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
edit_user
edit_user(request, user_id, user_attributtes, token_user_id, token_session_id, step_up_store, db, response, if_match)
Update user information.
A change of email, access type, active flag, username or email-verified flag needs the administrator's own
step-up verification in step_up (their current password or, for an account without one, a fresh
identity-provider sign-in, and an MFA code when MFA is enabled). A change of email, access type or active
flag also signs the edited user out everywhere; a new username does not, and the user is sent a security
notice of it. An edit that changes none of the five needs no step_up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_id
|
UuidId
|
ID of user to update. |
required |
user_attributtes
|
UserAdminEdit
|
User data to update, and the administrator's step-up. |
required |
token_user_id
|
CurrentUserId
|
ID of the administrator making the edit. |
required |
token_session_id
|
CurrentSessionId
|
Session ID of the administrator. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, which carries the new ETag. |
required |
if_match
|
IfMatch
|
The |
required |
Returns:
| Type | Description |
|---|---|
UserRead
|
Updated user data. |
Source code in backend/app/modules/users/users/router.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
edit_user_password
edit_user_password(request, user_id, user_attributes, token_user_id, token_session_id, step_up_store, db)
Update another user's password.
Requires the administrator's own step-up verification: their current password (or, for an account without one, a fresh identity-provider sign-in), and an MFA code when MFA is enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_id
|
UuidId
|
ID of user to update password for. |
required |
user_attributes
|
UserAdminEditPassword
|
New password data and the administrator's step-up. |
required |
token_user_id
|
CurrentUserId
|
ID of the administrator making the change. |
required |
token_session_id
|
CurrentSessionId
|
Session ID of the administrator. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
db
|
DbSession
|
Database session dependency. |
required |
Raises:
| Type | Description |
|---|---|
HTTPException
|
422 if the password is too short, too common or matches the account's details. |
Source code in backend/app/modules/users/users/router.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
get_user_identity_providers
get_user_identity_providers(user_id, page, db)
List one page of a specific user's identity provider links (admin).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
UuidId
|
ID of the user whose identity provider links to retrieve. |
required |
page
|
ListPage
|
The requested window. |
required |
db
|
DbSession
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
IdentityProviderLinkPage
|
The page of the user's enriched identity provider links, oldest first. |
Source code in backend/app/modules/users/users/router.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
put_user_image
put_user_image(request, user_id, file, storage, db, response)
Set a user's profile image.
Answers 201 when the user had no photo and 200 when it replaced one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_id
|
UuidId
|
ID of user to upload image for. |
required |
file
|
UploadFile
|
Uploaded image file. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, whose status is 200 when a photo was replaced. |
required |
Returns:
| Type | Description |
|---|---|
UserPhotoRead
|
The servable URL of the new photo. |
Source code in backend/app/modules/users/users/router.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
read_user
read_user(user_id, db, scopes, response)
Get a user by ID.
With users:read-all the answer is the full record, with its ETag. With only users:read it is the
public projection, and a user who is inactive or awaits approval is 404.
Source code in backend/app/modules/users/users/router.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
read_users
read_users(db, scopes, page, active=None, email_verified=None, pending_approval=None, external_auth=None, username=None, username_contains=None)
List users, one page at a time.
With users:read-all the page holds full records and every filter is available. With only users:read it
holds public projections of active users who are discoverable (those who switched off "Let others find me
in search" are left out; their profile stays reachable by id), a state filter is refused with 403, and a request
with neither username nor username_contains (at least 3 characters) is refused with 422.
num_records defaults to the server's page size and may not exceed it; a larger value is refused with 422.
Source code in backend/app/modules/users/users/router.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
require_user_password_change
require_user_password_change(request, user_id, body, token_user_id, token_session_id, step_up_store, db)
Require another user to choose a new password at their next sign-in.
Requires the administrator's own step-up verification: their current password (or, for an account without one, a fresh identity-provider sign-in), and an MFA code when MFA is enabled. The user keeps their current password until then, all of their sessions end and they are notified. A user without a local password is refused with 409; single sign-on sign-ins are unaffected.
Source code in backend/app/modules/users/users/router.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
reset_user_mfa
reset_user_mfa(request, user_id, body, token_user_id, token_session_id, step_up_store, db)
Reset another user's two-factor authentication.
Requires the administrator's own step-up verification: their current password (or, for an account without one, a fresh identity-provider sign-in), and an MFA code when MFA is enabled. The user's MFA secret and backup codes are removed, all of their sessions end and they are notified. A user without MFA is refused with 409.
Source code in backend/app/modules/users/users/router.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
User schema definitions for request and response models.
EmailChange
Bases: BaseModel
Self-service email change, authorised by step-up verification.
Attributes:
| Name | Type | Description |
|---|---|---|
email |
EmailStr
|
The new email address. |
revoke_other_sessions |
StrictBool
|
Whether to sign out the user's other sessions after the change. |
step_up |
StepUpVerification
|
The caller's step-up verification. |
Source code in backend/app/modules/users/users/schema.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | |
FirstAdminCreate
Bases: BaseModel
The only fields a caller supplies when the first administrator is created.
The access level and account state are not here: the users service sets them.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
UserRequestName
|
User's full name. |
username |
UserUsername
|
Unique username. |
email |
UserEmail
|
User's email address. |
password |
UserPassword
|
User's password (the administrator password policy applies). |
Source code in backend/app/modules/users/users/schema.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
Gender
Bases: Enum
User gender enumeration.
Attributes:
| Name | Type | Description |
|---|---|---|
MALE |
Male gender. |
|
FEMALE |
Female gender. |
|
UNSPECIFIED |
Unspecified or undisclosed gender. |
Source code in backend/app/modules/users/users/schema.py
32 33 34 35 36 37 38 39 40 41 42 43 | |
IdentityProviderLinkStart
Bases: BaseModel
Start linking an identity provider to the signed-in user's account, authorised by step-up verification.
Attributes:
| Name | Type | Description |
|---|---|---|
redirect |
StrictStr | None
|
Frontend return path after linking (a relative path or a configured native-app address). |
revoke_other_sessions |
StrictBool
|
Whether to sign out the user's other sessions once the link completes. |
step_up |
StepUpVerification
|
The caller's step-up verification. |
Source code in backend/app/modules/users/users/schema.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | |
Language
Bases: StrEnum
Supported application languages.
Attributes:
| Name | Type | Description |
|---|---|---|
CATALAN |
Catalan (ca). |
|
CHINESE_SIMPLIFIED |
Simplified Chinese (zh-Hans). |
|
CHINESE_TRADITIONAL |
Traditional Chinese (zh-Hant). |
|
GERMAN |
German (de). |
|
FRENCH |
French (fr). |
|
GALICIAN |
Galician (gl). |
|
ITALIAN |
Italian (it). |
|
DUTCH |
Dutch (nl). |
|
PORTUGUESE |
Portuguese (pt-PT). |
|
SLOVENIAN |
Slovenian (sl). |
|
SWEDISH |
Swedish (sv). |
|
SPANISH |
Spanish (es). |
|
ENGLISH |
English (en). |
|
POLISH |
Polish (pl). |
|
TURKISH |
Turkish (tr). |
|
UKRAINIAN |
Ukrainian (uk). |
|
ROMANIAN |
Romanian (ro). |
|
NORWEGIAN |
Norwegian Bokmål (nb). |
|
DANISH |
Danish (da). |
|
FINNISH |
Finnish (fi). |
|
CZECH |
Czech (cs). |
|
GREEK |
Greek (el). |
|
HUNGARIAN |
Hungarian (hu). |
|
BULGARIAN |
Bulgarian (bg). |
|
CROATIAN |
Croatian (hr). |
|
SERBIAN |
Serbian (sr). |
|
SLOVAK |
Slovak (sk). |
|
LITHUANIAN |
Lithuanian (lt). |
|
LATVIAN |
Latvian (lv). |
|
ESTONIAN |
Estonian (et). |
Source code in backend/app/modules/users/users/schema.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
ProfileUpdate
Bases: NotClearable, BaseModel
Schema for self-service profile updates.
Strict allow-list of fields the authenticated user is
permitted to change on their own account. Administrative
fields (access_type, active, mfa_enabled,
mfa_secret, email_verified,
pending_admin_approval) are intentionally excluded —
accepting them here would allow self-service privilege
escalation through mass assignment.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
DisplayName | None
|
User's full name. |
city |
StrictStr | None
|
User's city. |
birthdate |
RecordDate | None
|
User's birthdate. |
preferred_language |
Language | None
|
Preferred application language. |
gender |
Gender | None
|
User's gender. |
units |
Units | None
|
Preferred unit system. |
weight_units |
Units | None
|
Preferred weight units, independent of units; null follows units. |
height |
UserRequestHeight | None
|
User's height in centimeters. |
max_heart_rate |
StrictInt | None
|
Maximum heart rate in bpm. |
first_day_of_week |
WeekDay | None
|
First day of the week. |
currency |
Currency | None
|
Preferred currency. |
timezone |
IanaTimezone | None
|
IANA timezone the athlete lives in. |
Note
email is deliberately absent. It is the address password resets go to, so changing
it needs fresh proof of identity and is :class:EmailChange. username is deliberately absent
for the same reason: it is the sign-in name, so changing it is :class:UsernameChange.
photo_path is deliberately absent. The photo is a
server-issued storage key written only by the upload and
delete endpoints, so accepting it here would let a caller
repoint their avatar at another user's blob.
Source code in backend/app/modules/users/users/schema.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | |
User
Bases: UserBase
Complete users schema with administrative fields.
Note
mfa_secret is intentionally NOT part of any API-facing
schema. It lives only on the SQLAlchemy model and is
accessed directly by MFA verification utilities. Including
it in a Pydantic schema would risk leaking the encrypted
seed through responses, exports, logs, or future
model_dump callers.
Attributes:
| Name | Type | Description |
|---|---|---|
access_type |
UserAccessType
|
User access level. |
active |
StrictBool
|
Whether the user is active. |
email_verified |
StrictBool
|
Whether email is verified. |
Source code in backend/app/modules/users/users/schema.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
UserAccessType
Bases: StrEnum
User access level enumeration.
Attributes:
| Name | Type | Description |
|---|---|---|
REGULAR |
Standard user access. |
|
ADMIN |
Administrative access. |
Source code in backend/app/modules/users/users/schema.py
136 137 138 139 140 141 142 143 144 145 | |
UserAdminCreate
Bases: UserCreate
An administrator's creation of a user, the body of POST /users.
Attributes:
| Name | Type | Description |
|---|---|---|
step_up |
StepUpVerification | None
|
The administrator's own step-up verification. Required when the new account is an administrator's; it is never a user field. |
Source code in backend/app/modules/users/users/schema.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
to_create
to_create()
Return the user fields of the request, without the step-up.
Returns:
| Type | Description |
|---|---|
UserCreate
|
The user as a :class: |
Source code in backend/app/modules/users/users/schema.py
561 562 563 564 565 566 567 | |
UserAdminEdit
Bases: UserEdit
An administrator's edit of another user, the body of PATCH /users/{user_id}.
Attributes:
| Name | Type | Description |
|---|---|---|
step_up |
StepUpVerification | None
|
The administrator's own step-up verification. Required when the edit changes the email, the access type, the active flag, the username or the email-verified flag; it is never a user field. |
Source code in backend/app/modules/users/users/schema.py
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
to_edit
to_edit()
Return the user fields of the request, without the step-up.
Returns:
| Type | Description |
|---|---|
UserEdit
|
The edit as a :class: |
Source code in backend/app/modules/users/users/schema.py
879 880 881 882 883 884 885 | |
UserAdminEditPassword
Bases: BaseModel
Schema for admin password reset operations.
Setting another user's password needs the users:write scope and the administrator's own step-up
verification, not the target user's current password. Self-service password changes must use
:class:UserEditPassword instead.
Attributes:
| Name | Type | Description |
|---|---|---|
password |
StrictStr
|
New password (the account's password policy applies). |
step_up |
StepUpVerification
|
The administrator's own step-up verification. |
Source code in backend/app/modules/users/users/schema.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
UserBase
Bases: BaseModel
Base users schema with common fields.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
UserName
|
User's full name (1-250 chars). |
username |
UserUsername
|
Unique username (1-250 chars, alphanumeric and dots). |
email |
UserEmail
|
User's email address (max 250 chars). |
city |
StrictStr | None
|
User's city (max 250 chars). |
birthdate |
RecordDate | None
|
User's birthdate. |
preferred_language |
Language
|
Preferred language. |
gender |
Gender
|
User's gender. |
units |
Units
|
User units (metric, imperial). |
weight_units |
Units | None
|
Weight units override (metric - kg, imperial - lb); null follows units. |
height |
StrictInt | None
|
User's height in centimeters (1-300). |
max_heart_rate |
StrictInt | None
|
Maximum heart rate in bpm (30-250). |
first_day_of_week |
WeekDay
|
First day of the week. |
currency |
Currency
|
User currency (euro, dollar, pound). |
timezone |
IanaTimezone | None
|
IANA timezone the athlete lives in. |
Source code in backend/app/modules/users/users/schema.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
UserCreate
Bases: User
Users schema for admin user creation.
Attributes:
| Name | Type | Description |
|---|---|---|
password |
UserPassword | None
|
User's password (the account's password policy applies). Absent when the account is invited to choose its own, which needs mail and an active account. |
Source code in backend/app/modules/users/users/schema.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
UserDeletionStatus
Bases: JobStatusOpenFailure
Where a queued account deletion is.
Source code in backend/app/modules/users/users/schema.py
888 889 890 891 | |
UserEdit
Bases: ProfileUpdate
Users schema for an administrative edit, a partial one: a field left out is kept.
The profile fields a user may edit, plus the ones only an administrator sets. The stored columns of a user and
nothing a read adds: id is the path, and external_auth_count, the photo URL and the pending email
change are derived. mfa_enabled and pending_admin_approval are read-only projections and are not
fields. A name already stored is re-applied as it is, even if it would not pass as new input. A writer that
re-applies a whole user sends every field, as :meth:from_read does.
Attributes:
| Name | Type | Description |
|---|---|---|
username |
UserUsername | None
|
Unique username. |
email |
UserEmail | None
|
User's email address. |
access_type |
UserAccessType | None
|
User access level. |
active |
StrictBool | None
|
Whether the user is active. |
email_verified |
StrictBool | None
|
Whether email is verified. |
Source code in backend/app/modules/users/users/schema.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
from_read
classmethod
from_read(user)
Build the edit that re-applies a user as stored, for a caller that changes a few fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
UserRead
|
The user as read, usually with the changes already applied. |
required |
Returns:
| Type | Description |
|---|---|
UserEdit
|
The same user as an edit. |
Source code in backend/app/modules/users/users/schema.py
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
UserEditPassword
Bases: BaseModel
Schema for password update operations (self-service).
Requires the caller's step-up verification, in step_up, before the new password is accepted. This
prevents a stolen in-memory access token from being parlayed into permanent account takeover.
Attributes:
| Name | Type | Description |
|---|---|---|
password |
StrictStr
|
New password (the account's password policy applies). |
revoke_other_sessions |
StrictBool
|
Whether to sign out the user's other sessions after the change. |
step_up |
StepUpVerification
|
The caller's step-up verification: the current password and, when MFA is enabled, an MFA code. |
Source code in backend/app/modules/users/users/schema.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
UserMe
Bases: UserRead
Extended users schema for current user profile.
Includes privacy settings and integration status.
Attributes:
| Name | Type | Description |
|---|---|---|
privacy_settings_version |
StrictInt | None
|
Version of the privacy settings, for |
integrations_version |
StrictInt | None
|
Version of the integrations, for |
is_strava_linked |
StrictBool | None
|
Strava integration status. |
strava_revoked_at |
datetime | None
|
When Strava refused the refresh token, |
strava_data_deletion_at |
datetime | None
|
When the user's Strava data is deleted unless they relink, |
is_garminconnect_linked |
StrictBool | None
|
Garmin Connect status. |
default_activity_visibility |
ActivityVisibility | None
|
Default visibility level. |
hide_activity_start_time |
StrictBool | None
|
Hide start time setting. |
hide_activity_location |
StrictBool | None
|
Hide location setting. |
hide_activity_map |
StrictBool | None
|
Hide map setting. |
hide_activity_hr |
StrictBool | None
|
Hide heart rate setting. |
hide_activity_power |
StrictBool | None
|
Hide power setting. |
hide_activity_cadence |
StrictBool | None
|
Hide cadence setting. |
hide_activity_elevation |
StrictBool | None
|
Hide elevation setting. |
hide_activity_speed |
StrictBool | None
|
Hide speed setting. |
hide_activity_pace |
StrictBool | None
|
Hide pace setting. |
hide_activity_laps |
StrictBool | None
|
Hide laps setting. |
hide_activity_workout_sets_steps |
StrictBool | None
|
Hide workout sets/steps. |
hide_activity_gear |
StrictBool | None
|
Hide gear setting. |
discoverable |
StrictBool | None
|
Whether other users can find the user in username search. |
has_local_password |
StrictBool
|
Whether the account has a local password (False for an account with no password). |
Source code in backend/app/modules/users/users/schema.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
UserPhotoRead
Bases: BaseModel
The photo a user has after an upload.
Attributes:
| Name | Type | Description |
|---|---|---|
photo_path |
StrictStr | None
|
Servable URL of the user's photo, or None when none is stored. |
Source code in backend/app/modules/users/users/schema.py
648 649 650 651 652 653 654 655 | |
UserPublicRead
Bases: BaseModel
What any signed-in viewer, or an anonymous one on a shared link, may learn about a user.
A deliberate subset of :class:UserRead: no email, birthdate, access level or account
state, so a lookup cannot be used to harvest personal data or to probe who is an admin.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
User ID. |
name |
StrictStr
|
User's full name. |
username |
StrictStr
|
Unique username. |
city |
StrictStr | None
|
User's city. |
photo_path |
StrictStr | None
|
Servable URL of the user's photo. |
Source code in backend/app/modules/users/users/schema.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
UserRead
Bases: User
Users schema for read operations.
Attributes:
| Name | Type | Description |
|---|---|---|
mfa_enabled |
StrictBool
|
Whether MFA is enabled. |
pending_admin_approval |
StrictBool
|
Whether pending admin approval. |
id |
UUID
|
User ID. |
photo_path |
StrictStr | None
|
Servable URL of the user's photo, resolved from the stored storage key. |
external_auth_count |
StrictInt
|
Number of external auth providers. |
pending_email |
EmailStr | None
|
Address awaiting confirmation, which replaces |
pending_email_expires_at |
datetime | None
|
When the confirmation link for |
deletion_requested_at |
datetime | None
|
When the account was queued for deletion, |
Source code in backend/app/modules/users/users/schema.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
UserSignup
Bases: BaseModel
Users schema for a public sign-up request: only what an account needs.
The rest of the profile starts from the UserBase defaults and is edited after signing in.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
UserRequestName
|
User's full name (1-250 chars). |
username |
UserUsername
|
Unique username (1-250 chars, alphanumeric and dots). |
email |
UserEmail
|
User's email address (max 250 chars). |
password |
UserPassword | None
|
User's password; the account's password policy applies. Absent when the password is chosen at email verification. |
preferred_language |
Language
|
Language of the account's emails and interface. |
Source code in backend/app/modules/users/users/schema.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | |
UsernameChange
Bases: BaseModel
Self-service username change, authorised by step-up verification.
Attributes:
| Name | Type | Description |
|---|---|---|
username |
UserUsername
|
The new username. |
revoke_other_sessions |
StrictBool
|
Whether to sign out the user's other sessions after the change. |
step_up |
StepUpVerification
|
The caller's step-up verification. |
Source code in backend/app/modules/users/users/schema.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | |
WeekDay
Bases: Enum
Days of the week enumeration.
Attributes:
| Name | Type | Description |
|---|---|---|
SUNDAY |
Sunday. |
|
MONDAY |
Monday. |
|
TUESDAY |
Tuesday. |
|
WEDNESDAY |
Wednesday. |
|
THURSDAY |
Thursday. |
|
FRIDAY |
Friday. |
|
SATURDAY |
Saturday. |
Source code in backend/app/modules/users/users/schema.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
normalize_access_type
normalize_access_type(access_type)
Return the string value of an access type.
Accepts either a :class:UserAccessType enum member or its raw
string value and always returns the plain string form (e.g.
"admin" or "regular").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_type
|
UserAccessType | str
|
A |
required |
Returns:
| Type | Description |
|---|---|
str
|
The access type as a plain string. |
Source code in backend/app/modules/users/users/schema.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
Users profile
The profile router also serves the privacy settings routes (/profile/privacy). The profile's sessions, two-step verification and identity provider links (/profile/sessions, /profile/mfa and /profile/identity-providers) are served by the auth module; see Authentication.
Profile API endpoints for user management and operations.
This module provides FastAPI endpoints for: - User profile retrieval and updates - Password and privacy settings management - Profile photo upload and deletion - Profile data export and import
The signed-in user's own sessions, two-step verification and identity provider links are
served under the same /profile prefix by the auth module (modules.auth.sessions,
modules.auth.mfa and modules.auth.identity_providers, each in a profile_router).
cancel_profile_email_change
cancel_profile_email_change(request, token_user_id, db)
Cancel the pending email change, so its confirmation link stops working.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session. |
required |
Source code in backend/app/modules/users/users_profile/router.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
delete_my_account
delete_my_account(request, response, body, token_user_id, token_session_id, step_up_store, state, storage, mail, db)
Queue the deletion of the authenticated user's account and all of their data.
Requires step-up verification: the current password (or, for an account without one, a fresh identity-provider sign-in), and an MFA code when MFA is enabled. The account is signed out and deactivated at once and a background job erases the data, which is permanent and cannot be undone. Export the profile first to keep a copy. The browser's refresh-token cookie is cleared on the response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which receives the cookie-deletion headers. |
required |
body
|
StepUpRequest
|
The step-up verification. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
token_session_id
|
CurrentSessionId
|
Session ID from access token. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
state
|
PlatformState
|
The platform state provider. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
mail
|
Mail
|
The platform mail provider. |
required |
db
|
DbSession
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
UserDeletionStatus
|
The deletion's initial status. |
Source code in backend/app/modules/users/users_profile/router.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | |
delete_profile_photo
delete_profile_photo(request, token_user_id, storage, db)
Delete authenticated user's profile photo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
db
|
DbSession
|
Database session. |
required |
Source code in backend/app/modules/users/users_profile/router.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
download_profile_export
download_profile_export(request, token_user_id, token_session_id, export_states, storage)
Download the authenticated user's finished profile export.
Only the session that requested the export, and passed step-up for it, can download it; any other session gets 404, as when no finished export exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
token_session_id
|
CurrentSessionId
|
Session ID from access token. |
required |
export_states
|
ProfileExportStateStoreDep
|
Shared store of the export's state. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
Returns:
| Type | Description |
|---|---|
StreamingResponse
|
Streaming response with the ZIP archive. |
Source code in backend/app/modules/users/users_profile/router.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
edit_profile
edit_profile(request, response, user_attributtes, token_user_id, db, if_match)
Edit self-service profile fields for the authenticated user.
Uses an explicit allow-list (:class:users_schema.ProfileUpdate)
so administrative attributes such as access_type,
active, mfa_enabled, mfa_secret, email_verified,
and pending_admin_approval cannot be modified through this
endpoint, even if a malicious client submits them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which carries the user's new ETag. |
required |
user_attributtes
|
ProfileUpdate
|
Allow-listed profile updates. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session. |
required |
if_match
|
IfMatch
|
The |
required |
Returns:
| Type | Description |
|---|---|
UserMe
|
The edited profile; its |
Source code in backend/app/modules/users/users_profile/router.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
edit_profile_email
edit_profile_email(request, response, email_change, token_user_id, token_session_id, step_up_store, state, db)
Request a change of the authenticated user's email after step-up verification.
The address is where password resets go, so the caller must re-prove identity with the
current password (and an MFA code when MFA is enabled). The current address stays in place
until the link emailed to the new one is followed, and the new address is shown as
pending_email meanwhile. A later request replaces an earlier one, and the current address
cancels a pending change. When the server cannot send mail the address changes at once, unverified.
The user's other sessions are revoked when the request asks for it. The answer is the profile as it
stands afterwards, so the client can tell a pending change (pending_email) from an applied one.
An address another account holds is answered exactly like a free one, so the request does not reveal
which addresses are registered; that account's holder is emailed a notice instead of a confirmation link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which carries the user's current ETag. |
required |
email_change
|
EmailChange
|
The new address with the step-up verification. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
token_session_id
|
Annotated[UUID, Depends(get_sid_from_access_token)]
|
Session ID of the caller, preserved when other sessions are revoked. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
state
|
PlatformState
|
The platform state provider, for the notice cooldown. |
required |
db
|
DbSession
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
UserMe
|
The profile after the request; its |
Raises:
| Type | Description |
|---|---|
HTTPException
|
403 if step-up verification fails; 409 if another account uses the address and the server cannot send mail. |
Source code in backend/app/modules/users/users_profile/router.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
edit_profile_password
edit_profile_password(request, user_attributtes, token_user_id, token_session_id, step_up_store, db)
Update user password after step-up verification.
Requires the caller to re-prove identity in step_up with the current
password — and an MFA code when MFA is enabled — before the
new password is accepted. This prevents a stolen access
token alone from being parlayed into permanent account
takeover.
All of the user's other sessions are revoked after the change
while the current session is preserved, unless the request sets
revoke_other_sessions to false, so a password change evicts
a suspected attacker without logging the caller out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_attributtes
|
UserEditPassword
|
Schema with the new password, the step-up
verification, and the optional |
required |
token_user_id
|
CurrentUserId
|
ID of the user extracted from the access token. |
required |
token_session_id
|
Annotated[UUID, Depends(get_sid_from_access_token)]
|
Session ID of the caller, preserved when other sessions are revoked. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
db
|
DbSession
|
Database session. |
required |
Raises:
| Type | Description |
|---|---|
StepUpFailedError
|
403 |
PasswordPolicyError
|
422 if the new password is too short, too common or matches the account's details. |
Source code in backend/app/modules/users/users_profile/router.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
edit_profile_privacy_settings
edit_profile_privacy_settings(request, response, user_privacy_settings, token_user_id, db, if_match)
Edit privacy settings for authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which carries the settings' new ETag. |
required |
user_privacy_settings
|
UserPrivacySettingsUpdate
|
New privacy settings. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session. |
required |
if_match
|
IfMatch
|
The |
required |
Returns:
| Type | Description |
|---|---|
UserPrivacySettingsRead
|
The edited settings; their |
Source code in backend/app/modules/users/users_profile/router.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
edit_profile_username
edit_profile_username(request, response, username_change, token_user_id, token_session_id, step_up_store, db)
Change the authenticated user's username after step-up verification.
The username is the sign-in name, so the caller must re-prove identity with the current password (and an MFA code when MFA is enabled). It is stored in lower case, and re-submitting the current username changes nothing. The user's other sessions are revoked when the request asks for it, and the account's email address is told of the change. The answer is the updated profile.
Source code in backend/app/modules/users/users_profile/router.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
export_profile_data
export_profile_data(request, response, body, token_user_id, token_session_id, step_up_store, export_states, db)
Queue an export of all profile data as a ZIP archive.
Requires step-up verification: the current password (or, for an account without one, a fresh
identity-provider sign-in), and an MFA code when MFA is enabled. A worker builds the archive;
poll GET /jobs/{job_id} for the outcome and fetch it from GET /profile/export/download.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which names the job and when to poll it. |
required |
body
|
StepUpRequest
|
The step-up verification. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
token_session_id
|
CurrentSessionId
|
Session ID from access token. |
required |
step_up_store
|
Annotated[StepUpStore, Depends(get_step_up_attempts)]
|
Step-up lockout store. |
required |
export_states
|
ProfileExportStateStoreDep
|
Shared store of the export's state. |
required |
db
|
DbSession
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ProfileExportStatus
|
The queued export's status. |
Source code in backend/app/modules/users/users_profile/router.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
import_profile_data
import_profile_data(request, response, file, token_user_id, import_states, storage, db)
Queue a profile import from a ZIP archive.
The archive is validated and staged, and a worker imports it; poll GET /jobs/{job_id} for
the outcome. The database part is all-or-nothing, so a failed import leaves nothing behind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
response
|
Response
|
The response, which names the job and when to poll it. |
required |
file
|
UploadFile
|
ZIP file containing profile data. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
import_states
|
ProfileImportStateStoreDep
|
Shared store of the import's state. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
db
|
DbSession
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ProfileImportStatus
|
The queued import's status. |
Source code in backend/app/modules/users/users_profile/router.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
put_profile_image
put_profile_image(request, file, token_user_id, storage, db, response)
Set the authenticated user's profile image, with security validation.
Answers 201 when the user had no photo and 200 when it replaced one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
file
|
UploadFile
|
Image file to upload. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
storage
|
Storage
|
The platform storage provider. |
required |
db
|
DbSession
|
Database session. |
required |
response
|
Response
|
The response, whose status is 200 when a photo was replaced. |
required |
Returns:
| Type | Description |
|---|---|
UserPhotoRead
|
The servable URL of the new photo. |
Source code in backend/app/modules/users/users_profile/router.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
read_profile_privacy_settings
read_profile_privacy_settings(token_user_id, db, response)
Retrieve the authenticated user's privacy settings.
The ETag is the settings' version, which a later PATCH /profile/privacy echoes in If-Match.
Source code in backend/app/modules/users/users_profile/router.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
read_users_me
read_users_me(token_user_id, db, response)
Retrieve authenticated user profile with integrations.
The ETag is the user's version, which a later PATCH /profile echoes in If-Match. The
privacy settings have their own version, privacy_settings_version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session. |
required |
response
|
Response
|
The response, which carries the user's ETag. |
required |
Returns:
| Type | Description |
|---|---|
UserMe
|
User object with integration and privacy settings. |
Source code in backend/app/modules/users/users_profile/router.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
resend_profile_email_change
resend_profile_email_change(request, token_user_id, state, db)
Send the confirmation email of the pending email change again.
The answer is the same whether or not an email was queued: there may be no pending change, the server may not send mail, or an email may already have gone out within the cooldown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
state
|
PlatformState
|
The platform state provider, for the resend cooldown. |
required |
db
|
DbSession
|
Database session. |
required |
Source code in backend/app/modules/users/users_profile/router.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
Pydantic response shapes for the profile import and export.
ProfileExportStatus
Bases: JobStatus
Where the authenticated user's profile export is.
Attributes:
| Name | Type | Description |
|---|---|---|
error_code |
ExportFailure | None
|
Why the export failed; set only when it failed. |
size_bytes |
int | None
|
Size of the archive; set only when it succeeded and can be downloaded. |
expires_at |
datetime | None
|
When the download stops working; set only when it succeeded and can be downloaded. |
Source code in backend/app/modules/users/users_profile/schema.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
ProfileImportStatus
Bases: JobStatus
Where the authenticated user's profile import is.
Attributes:
| Name | Type | Description |
|---|---|---|
error_code |
ImportFailure | None
|
Why the import failed; set only when it failed. |
imported |
dict[str, int] | None
|
How many items of each kind were imported; set only when it succeeded. |
Source code in backend/app/modules/users/users_profile/schema.py
36 37 38 39 40 41 42 43 44 45 46 | |
UserProfileOverviewRead
Bases: BaseModel
Public profile and summary metrics displayed on a user's profile page.
Attributes:
| Name | Type | Description |
|---|---|---|
user |
UserPublicRead
|
The profile's public user projection. |
week_stats |
ActivityStatsRead
|
Visible per-sport activity totals for the current week. |
month_stats |
ActivityStatsRead
|
Visible per-sport activity totals for the current month. |
month_activity_count |
int
|
Visible activity count for the current month. |
followers_count |
int | None
|
Accepted followers, or None when the viewer cannot see the network. |
following_count |
int | None
|
Accepted followees, or None when the viewer cannot see the network. |
Source code in backend/app/modules/users/users_profile/schema.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Users goals
User goals API endpoints.
create_user_goal
create_user_goal(request, user_goal, token_user_id, db, response)
Create a new goal for the authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_goal
|
UserGoalCreate
|
Goal data to create. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, whose |
required |
Returns:
| Type | Description |
|---|---|
UserGoalRead
|
The created goal object. |
Source code in backend/app/modules/users/users_goals/router.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
delete_user_goal
delete_user_goal(request, goal_id, token_user_id, if_match, db)
Delete a goal for the authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
goal_id
|
UuidId
|
ID of the goal to delete. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
if_match
|
IfMatch
|
The |
required |
db
|
DbSession
|
Database session dependency. |
required |
Raises:
| Type | Description |
|---|---|
PreconditionFailedError
|
If the goal changed since the client read it. |
Source code in backend/app/modules/users/users_goals/router.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_user_goal
get_user_goal(goal_id, token_user_id, db, response)
Retrieve one of the authenticated user's goals; its ETag is the version for If-Match.
Source code in backend/app/modules/users/users_goals/router.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get_user_goals
get_user_goals(token_user_id, page, db, interval=None, activity_type=None, goal_type=None)
Retrieve one page of goals for the authenticated user with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
page
|
ListPage
|
The requested window. |
required |
db
|
DbSession
|
Database session dependency. |
required |
interval
|
Annotated[Interval | None, Query(description='Filter by goal interval')]
|
Optional filter by goal interval. |
None
|
activity_type
|
Annotated[GoalActivityType | None, Query(description='Filter by activity type')]
|
Optional filter by activity type. |
None
|
goal_type
|
Annotated[GoalType | None, Query(description='Filter by goal type')]
|
Optional filter by goal type. |
None
|
Returns:
| Type | Description |
|---|---|
UserGoalPage
|
The page of user goals matching the filters. |
Source code in backend/app/modules/users/users_goals/router.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
get_user_goals_results
get_user_goals_results(request, token_user_id, page, db)
Calculate and retrieve one page of goal progress for the authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
page
|
ListPage
|
The requested window. |
required |
db
|
DbSession
|
Database session dependency. |
required |
Returns:
| Type | Description |
|---|---|
UserGoalProgressPage
|
The page of goal progress objects, empty if no goals. |
Source code in backend/app/modules/users/users_goals/router.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
update_user_goal
update_user_goal(request, goal_id, user_goal, token_user_id, db, response, if_match)
Replace an existing goal for the authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
goal_id
|
UuidId
|
ID of the goal to replace. |
required |
user_goal
|
UserGoalUpdate
|
The goal's new values. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, which carries the new ETag. |
required |
if_match
|
IfMatch
|
The |
required |
Returns:
| Type | Description |
|---|---|
UserGoalRead
|
The updated goal object. |
Source code in backend/app/modules/users/users_goals/router.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
User goals Pydantic schemas and validators.
GoalActivityType
Bases: StrEnum
Supported activity types for user goals.
Attributes:
| Name | Type | Description |
|---|---|---|
RUN |
Running activities. |
|
BIKE |
Cycling activities. |
|
SWIM |
Swimming activities. |
|
WALK |
Walking or hiking activities. |
|
STRENGTH |
Strength or resistance training. |
|
CARDIO |
Cardiovascular training. |
Source code in backend/app/modules/users/users_goals/schema.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
GoalType
Bases: StrEnum
Types of measurable user goals.
Attributes:
| Name | Type | Description |
|---|---|---|
CALORIES |
Target calories burned. |
|
ACTIVITIES |
Target count of completed activities. |
|
DISTANCE |
Target distance traveled. |
|
ELEVATION |
Target elevation gain. |
|
DURATION |
Target total duration. |
Source code in backend/app/modules/users/users_goals/schema.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
Interval
Bases: StrEnum
Recurrence intervals for user goals.
Attributes:
| Name | Type | Description |
|---|---|---|
DAILY |
Daily recurrence interval. |
|
WEEKLY |
Weekly recurrence interval. |
|
MONTHLY |
Monthly recurrence interval. |
|
YEARLY |
Yearly recurrence interval. |
Source code in backend/app/modules/users/users_goals/schema.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
UserGoalBase
Bases: BaseModel
Base schema for users fitness goals.
Attributes:
| Name | Type | Description |
|---|---|---|
interval |
Interval
|
Goal time interval (daily, weekly, monthly, yearly). |
activity_type |
GoalActivityType
|
Type of activity for the goal. |
goal_type |
GoalType
|
Type of goal metric being tracked. |
goal_calories |
StrictInt | None
|
Target calories in kcal. |
goal_activities_number |
StrictInt | None
|
Target number of activities. |
goal_distance |
StrictInt | None
|
Target distance in meters. |
goal_elevation |
StrictInt | None
|
Target elevation gain in meters. |
goal_duration |
StrictInt | None
|
Target duration in seconds. |
Source code in backend/app/modules/users/users_goals/schema.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
ensure_correct_goal_field
ensure_correct_goal_field()
Validate exactly one goal field matches goal_type.
Returns:
| Type | Description |
|---|---|
UserGoalBase
|
Self with validated goal field. |
Raises:
| Type | Description |
|---|---|
PydanticCustomError
|
If required field missing or extra fields set. |
Source code in backend/app/modules/users/users_goals/schema.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
UserGoalCreate
Bases: _UserGoalWrite
Schema for creating a new users goal.
Inherits all validation from UserGoalBase.
Source code in backend/app/modules/users/users_goals/schema.py
185 186 187 188 189 | |
UserGoalProgress
Bases: BaseModel
Schema for user goal progress tracking.
Attributes:
| Name | Type | Description |
|---|---|---|
goal_id |
UUID
|
Goal identifier. |
interval |
Interval
|
Goal time interval. |
activity_type |
GoalActivityType
|
Activity type for this goal. |
goal_type |
GoalType
|
Type of goal metric. |
start_date |
date
|
Period start date. |
end_date |
date
|
Period end date. |
percentage_completed |
StrictInt | None
|
Completion percentage. |
total_calories |
StrictInt | None
|
Total calories achieved. |
total_activities_number |
StrictInt | None
|
Total activities completed. |
total_distance |
StrictInt | None
|
Total distance achieved. |
total_elevation |
StrictInt | None
|
Total elevation gained. |
total_duration |
StrictInt | None
|
Total duration achieved. |
goal_calories |
StrictInt | None
|
Target calories. |
goal_activities_number |
StrictInt | None
|
Target activities count. |
goal_distance |
StrictInt | None
|
Target distance. |
goal_elevation |
StrictInt | None
|
Target elevation. |
goal_duration |
StrictInt | None
|
Target duration. |
Source code in backend/app/modules/users/users_goals/schema.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
UserGoalRead
Bases: UserGoalBase
Schema for reading a user goal.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique identifier for the goal. |
user_id |
UUID
|
User who owns this goal. |
Source code in backend/app/modules/users/users_goals/schema.py
192 193 194 195 196 197 198 199 200 201 202 | |
UserGoalUpdate
Bases: _UserGoalWrite
Schema for replacing an existing users goal.
The goal is named by the path, so the body carries neither an id nor an owner. It is the whole goal, because the goal type decides which target field is required.
Source code in backend/app/modules/users/users_goals/schema.py
209 210 211 212 213 214 | |
Users default gear
User default gear API endpoints.
edit_user_default_gear
edit_user_default_gear(request, user_default_gear, token_user_id, db, response, if_match)
Update default gear settings for authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The incoming request, read by the rate limiter. |
required |
user_default_gear
|
UserDefaultGearUpdate
|
Updated gear settings. |
required |
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, which carries the new ETag. |
required |
if_match
|
IfMatch
|
The |
required |
Returns:
| Type | Description |
|---|---|
UserDefaultGearRead
|
Updated user default gear settings. |
Source code in backend/app/modules/users/users_default_gear/router.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
read_user_default_gear
read_user_default_gear(token_user_id, db, response)
Retrieve default gear settings for authenticated user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_user_id
|
CurrentUserId
|
User ID from access token. |
required |
db
|
DbSession
|
Database session dependency. |
required |
response
|
Response
|
The response, which carries the settings' ETag. |
required |
Returns:
| Type | Description |
|---|---|
UserDefaultGearRead | None
|
User default gear settings. |
Source code in backend/app/modules/users/users_default_gear/router.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
User default gear Pydantic schemas.
UserDefaultGearBase
Bases: BaseModel
Base schema for users default gear assignments.
Attributes:
| Name | Type | Description |
|---|---|---|
run_gear_id |
UUID | None
|
Default gear for run activities. |
trail_run_gear_id |
UUID | None
|
Default gear for trail run activities. |
virtual_run_gear_id |
UUID | None
|
Default gear for virtual run activities. |
ride_gear_id |
UUID | None
|
Default gear for ride activities. |
gravel_ride_gear_id |
UUID | None
|
Default gear for gravel ride activities. |
mtb_ride_gear_id |
UUID | None
|
Default gear for MTB ride activities. |
virtual_ride_gear_id |
UUID | None
|
Default gear for virtual ride activities. |
ows_gear_id |
UUID | None
|
Default gear for open water swim activities. |
walk_gear_id |
UUID | None
|
Default gear for walk activities. |
hike_gear_id |
UUID | None
|
Default gear for hike activities. |
tennis_gear_id |
UUID | None
|
Default gear for tennis activities. |
alpine_ski_gear_id |
UUID | None
|
Default gear for alpine ski activities. |
nordic_ski_gear_id |
UUID | None
|
Default gear for nordic ski activities. |
snowboard_gear_id |
UUID | None
|
Default gear for snowboard activities. |
windsurf_gear_id |
UUID | None
|
Default gear for windsurf activities. |
Source code in backend/app/modules/users/users_default_gear/schema.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
UserDefaultGearRead
Bases: UserDefaultGearBase
Schema for reading user default gear settings.
Extends base with identifier fields.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique identifier for the record. |
user_id |
UUID
|
User ID reference. |
Source code in backend/app/modules/users/users_default_gear/schema.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
UserDefaultGearUpdate
Bases: UserDefaultGearBase
Schema for updating user default gear settings.
Carries only the gear assignments, all optional for partial updates. The record is the authenticated user's own, so the body names neither the record nor the user.
Source code in backend/app/modules/users/users_default_gear/schema.py
125 126 127 128 129 130 | |
Users integrations
User integrations Pydantic schemas and validators.
UserIntegrationsBase
Bases: BaseModel
Base schema for user integrations.
Attributes:
| Name | Type | Description |
|---|---|---|
strava_client_id |
StrictStr | None
|
Encrypted Strava client ID. |
strava_client_secret |
StrictStr | None
|
Encrypted Strava client secret. |
strava_token |
StrictStr | None
|
Encrypted Strava access token. |
strava_refresh_token |
StrictStr | None
|
Encrypted Strava refresh token. |
strava_token_expires_at |
datetime | None
|
Strava token expiration time. |
strava_sync_gear |
StrictBool
|
Enable Strava gear synchronization. |
garminconnect_token |
dict[str, Any] | None
|
Garmin Connect token data. |
garminconnect_sync_gear |
StrictBool
|
Enable Garmin Connect gear synchronization. |
Source code in backend/app/modules/users/users_integrations/schema.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
UserIntegrationsCreate
Bases: UserIntegrationsBase
Pydantic model for creating user integrations.
Inherits all attributes from UserIntegrationsBase.
Source code in backend/app/modules/users/users_integrations/schema.py
67 68 69 70 71 | |
UserIntegrationsRead
Bases: UserIntegrationsBase
Schema for reading user integrations.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique identifier for the integrations record. |
user_id |
UUID
|
Foreign key reference to the user. |
version |
StrictInt
|
Optimistic-concurrency counter. |
strava_revoked_at |
datetime | None
|
When Strava refused the refresh token, |
Source code in backend/app/modules/users/users_integrations/schema.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
UserIntegrationsUpdate
Bases: UserIntegrationsBase
Schema for updating user integrations.
Inherits all validation from UserIntegrationsBase. All fields are optional for partial updates.
Source code in backend/app/modules/users/users_integrations/schema.py
74 75 76 77 78 79 | |
Users privacy settings
User privacy settings Pydantic schemas and validators.
UserPrivacySettingsBase
Bases: BaseModel
Base schema for user privacy settings.
Attributes:
| Name | Type | Description |
|---|---|---|
default_activity_visibility |
ActivityVisibility | None
|
Default activity visibility level. |
hide_activity_start_time |
StrictBool | None
|
Hide start time from activities. |
hide_activity_location |
StrictBool | None
|
Hide location data from activities. |
hide_activity_map |
StrictBool | None
|
Hide map visualization from activities. |
hide_activity_hr |
StrictBool | None
|
Hide heart rate data from activities. |
hide_activity_power |
StrictBool | None
|
Hide power data from activities. |
hide_activity_cadence |
StrictBool | None
|
Hide cadence data from activities. |
hide_activity_elevation |
StrictBool | None
|
Hide elevation data from activities. |
hide_activity_speed |
StrictBool | None
|
Hide speed data from activities. |
hide_activity_pace |
StrictBool | None
|
Hide pace data from activities. |
hide_activity_laps |
StrictBool | None
|
Hide lap data from activities. |
hide_activity_workout_sets_steps |
StrictBool | None
|
Hide workout sets and steps from activities. |
hide_activity_gear |
StrictBool | None
|
Hide gear information from activities. |
discoverable |
StrictBool | None
|
Appear in other users' username search. |
Source code in backend/app/modules/users/users_privacy_settings/schema.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
UserPrivacySettingsCreate
Bases: UserPrivacySettingsBase
Pydantic model for creating user privacy settings.
Inherits all attributes from UserPrivacySettingsBase.
Source code in backend/app/modules/users/users_privacy_settings/schema.py
73 74 75 76 77 | |
UserPrivacySettingsRead
Bases: UserPrivacySettingsBase
Schema for reading user privacy settings.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Unique identifier for the privacy settings record. |
user_id |
UUID
|
Foreign key reference to the user. |
Source code in backend/app/modules/users/users_privacy_settings/schema.py
105 106 107 108 109 110 111 112 113 114 115 | |
UserPrivacySettingsUpdate
Bases: NotClearable, UserPrivacySettingsBase
Schema for updating user privacy settings.
Inherits all validation from UserPrivacySettingsBase. All fields are optional for partial updates.
Source code in backend/app/modules/users/users_privacy_settings/schema.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |