Skip to main content

Module auth

Module auth 

Source
Expand description

Handlers for HTTP requests to /api/v0/auth.

Structsยง

AuthRoutesApiDoc
CreateAccountDetails
EmailCode
Login
SendEmailCodeData
UserInfo
Generic information about the logged in user.
VerifyEmailRequest

Enumsยง

DeleteUserAccountResult
Outcome of spending an account deletion code.
LoginResponse
SendDeleteUserEmailCodeResult
Outcome of asking for an account deletion code.
SignupResponse
TmcDeletionFailure ๐Ÿ”’
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 password for user_id, trying the seeded test-mode credentials before falling back to the stored password hash.
authorize_action_on_resource
POST /api/v0/auth/authorize checks whether user can perform specified action on specified resource.
authorize_multiple_actions_on_resources
POST /api/v0/auth/authorize-multiple checks 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-account If 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-in Returns the current userโ€™s login status.
login
POST /api/v0/auth/login Logs in to the system. Returns LoginResponse indicating success, email verification required, or failure.
logout
POST /api/v0/auth/logout Logs out.
report_tmc_deletion_rejection ๐Ÿ”’
Records a TMC refusal under reference in error_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-code If users password is correct, sends a code to users email for account deletion
signup
POST /api/v0/auth/signup Creates new mooc.fi account and signs in.
update_user_information_to_tmc
Copies a changed name, and email when it changed too, to TMC, which keeps its own copy of both; a no-op for an account without a TMC upstream_id. Callers run it inside their transaction so a TMC failure rolls the change back.
user_info
GET /api/v0/auth/user-info Returns the current userโ€™s info.
verify_email
POST /api/v0/auth/verify-email Verifies email verification code and completes login.