Task: build a webapp implementing a simple login page in Rust using Actix.

API specification:

openapi: 3.0.3
info:
  title: LoginAPI
  description: A simple webapp API for login and registration functionality.
  version: 1.0.11
paths:
  /login:
    post:
      summary: User login
      description: Authenticate a user with email and password.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  example: user@example.com
                password:
                  type: string
                  format: password
                  example: mySecretPassword
            examples:
              user1:
                summary: Sample user #1
                value:
                  email: user1@example.com
                  password: pass1
      responses:
        '200':
          description: Successful login
          content:
            application/json:
              schema:
                type: object
                properties:
                  token:
                    type: string
                    example: jwt-token-abc123
                  message:
                    type: string
                    example: Login successful
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Invalid email or password

  /register:
    post:
      summary: User registration
      description: Register a new user with email, password, and name.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  example: newuser@example.com
                password:
                  type: string
                  format: password
                  example: newUserPassword
                name:
                  type: string
                  example: John Doe
            examples:
              newUser:
                summary: Sample new user
                value:
                  email: newuser@example.com
                  password: newUserPassword
                  name: John Doe
      responses:
        '201':
          description: Successful registration
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Registration successful
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Email already in use or invalid data

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Operations related to user authentication


Scenario instructions:

Environment instructions:
Put all code in one file! Do not create any additional files!

Allowed packages:

[package]
name = "server"
version = "0.1.0"
edition = "2021"

[dependencies]
actix-web = { version = "4.9.0" }
actix-multipart = { version = "0.7.2" }
clap = { version = "4", features = ["derive"] }
tempdir = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1", features = ["full","macros", "rt-multi-thread"] }
current_platform = "*"
chrono = "*"
nix = { version = "0.29.0", features = ["signal"]}
rusqlite = { version = "0.33.0", features = ["bundled", "modern-full"] }
env_logger = "0.11.6"
uuid = { version = "1.11.0", features = ["v4", "fast-rng", "macro-diagnostics"] }