CreateClientUsers

struct CreateClientUsers : AsyncMigration

A Migration that creates a set of registered client users during startup, from a registered-clients.txt file located in the seeds/ subdirectory of the project. The file must be of the format:

clientUsername1:password1:recoveryKey1 clientUsername2:password2:recoveryKey2 …

Note

Each API client that wishes to make use of ClientController endpoints must provide a client username:password:recovery key triplet prior to production startup.
  • Declaration

    Swift

    struct ClientUserData
  • prepare(on:) Asynchronous

    Required by Migration protocol. Reads either a test or production text file in the seeds/ subdirectory, converts the lines into elements of an array, then iterates over them to create new User models with UserAccessLevel of .client.

    Requires

    registered-clients.txt file in seeds subdirectory.

    Declaration

    Swift

    func prepare(on database: Database) async throws

    Parameters

    conn

    A connection to the database, provided automatically.

    Return Value

    Void.

  • revert(on:) Asynchronous

    Required by Migration protocol, but this isn’t a model update, so just return a pre-completed Future.

    Declaration

    Swift

    func revert(on database: Database) async throws

    Parameters

    conn

    The database connection.

    Return Value

    Void.

  • Declaration

    Swift

    func getClients() -> [ClientUserData]