UserLogin:
  get:
    tags:
      - login
    summary: Log in to the site
    description: Log in to the site through a code from the server
    operationId: login
    parameters:
      - $ref: '#/components/parameters/Code'
    responses:
      '200':
        description: Logged in
        content:
          text/plain:
            schema:
              type: string
              description: A JWT token for this user
      '401':
        description: Login failed - Invalid credentials
        content:
          application/text:
            schema:
              $ref: '../generic/errors.yml#/components/schemas/ApiError'
      default:
        description: Unexpected error
        content:
          application/text:
            schema:
              $ref: '../generic/errors.yml#/components/schemas/ApiError'
RequestNewUserLogin:
  get:
    tags:
      - login
    summary: Request a login
    description: Request a code, that can be used to log in
    operationId: requestLogin
    parameters:
      - name: Authorization
        in: header
        required: true
        schema:
          type: string
          description: Secret
      - $ref: '../generic/parameters.yml#/components/parameters/Uuid'
    responses:
      '200':
        description: Success
        content:
          application/text:
            schema:
              type: string
              description: code to log in with
      '401':
        description: Login failed - Invalid secret
        content:
          application/json:
            schema:
              $ref: '../generic/errors.yml#/components/schemas/ApiError'
      default:
        description: Unexpected error
        content:
          application/json:
            schema:
              $ref: '../generic/errors.yml#/components/schemas/ApiError'
GetUsername:
  get:
    tags:
      - login
    summary: Get the username for the logged in user
    operationId: getUsername
    security:
      - bearerAuth: [ ]
    responses:
      '200':
        description: Username retrieved
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Username'
      default:
        description: Unexpected error
        content:
          application/json:
            schema:
              $ref: '../generic/errors.yml#/components/schemas/ApiError'
components:
  parameters:
    Code:
      name: code
      in: path
      required: true
      schema:
        type: string
        description: The code to log in with
  schemas:
    Username:
      properties:
        username:
          type: string
      required:
        - username
    LoginData:
      type: object
      required:
        - loginCode
      properties:
        loginCode:
          type: string
          description: The code to log in
    AddLogin:
      type: object
      required:
        - uuid
      properties:
        uuid:
          type: string
          format: uuid
          description: UUID of the user that will get logged in
