Expand description
Handlers for HTTP requests to /api/v0/auth.
Structsยง
- Auth
Routes ApiDoc - Create
Account Details - Email
Code - Login
- Send
Email Code Data - User
Info - Generic information about the logged in user.
- Verify
Email Request
Enumsยง
- Delete
User Account Result - Outcome of spending an account deletion code.
- Login
Response - Send
Delete User Email Code Result - Outcome of asking for an account deletion code.
- Signup
Response - TmcDeletion
Failure ๐ - How a failed TMC delete should be treated. The upstream status is what separates a retry that may work from one that never will.
Functionsยง
- _add_
routes - authenticate_
by_ ๐password - Verifies
passwordforuser_id, trying the seeded test-mode credentials before falling back to the stored password hash. - authorize_
action_ on_ resource - POST
/api/v0/auth/authorizechecks whether user can perform specified action on specified resource. - authorize_
multiple_ actions_ on_ resources - POST
/api/v0/auth/authorize-multiplechecks whether user can perform specified action on specified resource. Returns booleans for the authorizations in the same order as the input. - classify_
tmc_ ๐deletion_ failure - delete_
user_ account - POST
/api/v0/auth/delete-user-accountIf users single-use code is correct then delete users account - handle_
email_ ๐verification - handle_
production_ ๐login - handle_
test_ ๐mode_ login - handle_
test_ ๐mode_ signup - handle_
uuid_ ๐login - is_
duplicate_ ๐email_ error_ message - logged_
in - GET
/api/v0/auth/logged-inReturns the current userโs login status. - login
- POST
/api/v0/auth/loginLogs in to the system. Returns LoginResponse indicating success, email verification required, or failure. - logout
- POST
/api/v0/auth/logoutLogs out. - report_
tmc_ ๐deletion_ rejection - Records a TMC refusal under
referenceinerror_variants/error_occurrences, so support can find it from the reference alone. - requires_
login_ ๐code - Whether a production login must also be confirmed with an emailed code. Any role at any scope counts: a teacherโs account is as worth stealing as an adminโs. Test-mode and UUID logins skip it, since the system tests have no mail capture.
- send_
delete_ user_ email_ code - POST
/api/v0/auth/send-email-codeIf users password is correct, sends a code to users email for account deletion - signup
- POST
/api/v0/auth/signupCreates new mooc.fi account and signs in. - update_
user_ information_ to_ tmc - Copies a changed name, and
emailwhen it changed too, to TMC, which keeps its own copy of both; a no-op for an account without a TMCupstream_id. Callers run it inside their transaction so a TMC failure rolls the change back. - user_
info - GET
/api/v0/auth/user-infoReturns the current userโs info. - verify_
email - POST
/api/v0/auth/verify-emailVerifies email verification code and completes login.