CreateAdminUsers

struct CreateAdminUsers : AsyncMigration

A Migration that creates the admin user upon startup. The password and recovery key are read from environment variables ADMIN_PASSWORD and RECOVERY_KEY if present, otherwise defaults are used.

The defaults are intended and fine for development and testing, but should never be used in production. If not set to proper values in docker-compose.yml (or whatever other environment of your choice), reminders are printed to console during startup.

  • prepare(on:) Asynchronous

    Required by Migration protocol. Creates the admin user after a bit of sanity check caution.

    Declaration

    Swift

    func prepare(on database: Database) async throws

    Parameters

    database

    A connection to the database, provided automatically.

    Return Value

    Void.

  • revert(on:) Asynchronous

    Required by Migration protocol. Deletes all admin users.

    Declaration

    Swift

    func revert(on database: Database) async throws

    Parameters

    conn

    The database connection.

    Return Value

    Void.

  • createAdminUser(on:) Asynchronous

    Admin user gets their password and recovery key from the ADMIN_PASSWORD and ADMIN_RECOVERY_KEY environment variables. These are usually set in the appropriate .env file in “Private Swiftarr Config” directory. For the production environment, this file will be “production.env”.

    Declaration

    Swift

    func createAdminUser(on database: Database) async throws
  • Prometheus user gets their password from the PROMETHEUS_PASSWORD. Recovery key is randomly generated and thrown away. environment variables. These are usually set in the appropriate .env file in “Private Swiftarr Config” directory. For the production environment, this file will be “production.env”.

    Declaration

    Swift

    func createPrometheusUser(on database: Database) async throws
  • createTHOUser(on:) Asynchronous

    THO is a special acct for JoCo home office. There’s several specific things this account can do, such as settings announcements and daily themes. This account’s password and recovery key are set up in the same way as the admin acct.

    Declaration

    Swift

    func createTHOUser(on database: Database) async throws
  • By design, nobody can log in as Moderator–the password is set to a randomly-generated value that is immediately forgotten. However, anyone with moderotor access may post content as moderator, in which case the moderator account becomes the author of the content instead of the current user.

    “Content’ in this sense means tweets, forum posts, fez messages.

    Declaration

    Swift

    func createModeratorUser(on database: Database) async throws
  • By design, nobody can log in as TwitarrTeam–the password is set to a randomly-generated value that is immediately forgotten. However, anyone with TwitarrTeam access may post content as TwitarrTeam, in which case the TwitarrTeam account becomes the author of the content instead of the current user.

    “Content’ in this sense means tweets, forum posts, fez messages.

    Declaration

    Swift

    func createTwitarrTeamUser(on database: Database) async throws