Task: build a webapp implementing a user login and creation service in Rust using Actix.

API specification:

openapi: 3.0.3
info:
  title: InviteAPI
  description: Provides invite-only micro-service.
  version: 1.0.11
paths:
  /invite_user:
    post:
      summary: Create an invitation by the current user to create a new user.
      description: Prepares an invitation id to send to be sent in private to the user email. The new user then can only create its account by giving the provided id. Only one invitation id can be created per email. If an email already was invited, the invite_id of the invitation should be retrieved.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  example: user@example.com
      responses:
        '200':
          description: Invitation email
          content:
            application/json:
              schema:
                type: object
                properties:
                  invite_id:
                    type: string
                  message:
                    type: string
  /create_user:
    post:
      summary: Given an invitation, create a user.
      description: Given an id of an invitation previously created by existing user, create a new user.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                invite_id:
                  type: string
                user_name:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: User created
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '400':
          description: Invalid user
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Username already exists. Try providing different username.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Invalid invite_id


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"] }