|
# retoor <retoor@molodetz.nl>
|
|
|
|
from __future__ import annotations
|
|
|
|
from ..spec import Action
|
|
from ._shared import body, path
|
|
|
|
|
|
AUTH_ACTIONS: tuple[Action, ...] = (
|
|
Action(
|
|
name="auth_status",
|
|
method="GET",
|
|
path="",
|
|
summary="Report whether the current session is authenticated",
|
|
handler="status",
|
|
requires_auth=False,
|
|
),
|
|
Action(
|
|
name="login",
|
|
method="POST",
|
|
path="/auth/login",
|
|
summary="Authenticate with email and password and start a session",
|
|
handler="login",
|
|
requires_auth=False,
|
|
params=(
|
|
body("email", "Account email address.", required=True),
|
|
body("password", "Account password.", required=True),
|
|
body("remember_me", "Keep the session alive longer ('on' or '')."),
|
|
),
|
|
),
|
|
Action(
|
|
name="logout",
|
|
method="GET",
|
|
path="/auth/logout",
|
|
summary="End the current session",
|
|
handler="logout",
|
|
requires_auth=True,
|
|
),
|
|
Action(
|
|
name="signup",
|
|
method="POST",
|
|
path="/auth/signup",
|
|
summary="Create a new account",
|
|
requires_auth=False,
|
|
params=(
|
|
body("username", "Desired username.", required=True),
|
|
body("email", "Email address.", required=True),
|
|
body("password", "Password (minimum six characters).", required=True),
|
|
body("confirm_password", "Password confirmation.", required=True),
|
|
),
|
|
),
|
|
Action(
|
|
name="forgot_password",
|
|
method="POST",
|
|
path="/auth/forgot-password",
|
|
summary="Request a password reset email",
|
|
requires_auth=False,
|
|
params=(body("email", "Account email address.", required=True),),
|
|
),
|
|
Action(
|
|
name="reset_password",
|
|
method="POST",
|
|
path="/auth/reset-password/{token}",
|
|
summary="Reset a password using a reset token",
|
|
requires_auth=False,
|
|
params=(
|
|
path("token", "Reset token from the email link."),
|
|
body("password", "New password.", required=True),
|
|
body("confirm_password", "New password confirmation.", required=True),
|
|
),
|
|
),
|
|
)
|