Skip to main content

signup

Function signup 

Source
pub async fn signup(
    __arg0: State<DB>,
    __arg1: Json<SignupRequest>,
) -> (StatusCode, Json<SignupResponse>)
Expand description

Handles user signup requests

§Arguments

  • State(db) - Shared state containing the database connection and JWT configuration
  • Json(payload) - The signup request payload containing username, email, and password

§Returns

  • (StatusCode, Json<AuthTokenResponse>) - The HTTP status code and JSON response containing the authentication token or error message

§Error

  • StatusCode::INTERNAL_SERVER_ERROR - If there is an error processing the password, creating the user, generating tokens, or storing the refresh token
  • StatusCode::CONFLICT - If the username already exists
  • StatusCode::BAD_REQUEST - If there is a user ID mismatch during account deletion

§Example

let payload = SignupRequest {
    username: "newuser".to_string(),
    email: Some("newuser@example.com".to_string()),
    password: "password123".to_string(),
};