From 76857bb63022e0687b38bccc41895a498b561f4f Mon Sep 17 00:00:00 2001 From: Arthur Danjou Date: Fri, 18 Jun 2021 17:41:08 +0200 Subject: [PATCH] Add admin env variables --- .env.example | 3 +++ env.ts | 3 +++ providers/AppProvider.ts | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index b8b01f0..899c3cb 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,6 @@ MYSQL_PORT= MYSQL_USER= MYSQL_PASSWORD= MYSQL_DB_NAME= + +ADMIN_USER= +ADMIN_PASSWORD= diff --git a/env.ts b/env.ts index cd73166..4c2d2a4 100644 --- a/env.ts +++ b/env.ts @@ -20,6 +20,9 @@ export default Env.rules({ APP_KEY: Env.schema.string(), APP_URL: Env.schema.string(), + ADMIN_USER: Env.schema.string(), + ADMIN_PASSWORD: Env.schema.string(), + REDIS_HOST: Env.schema.string(), REDIS_PORT: Env.schema.number(), REDIS_PASSWORD: Env.schema.string.optional(), diff --git a/providers/AppProvider.ts b/providers/AppProvider.ts index 40d2ee0..3e2eb4a 100644 --- a/providers/AppProvider.ts +++ b/providers/AppProvider.ts @@ -1,4 +1,6 @@ import { ApplicationContract } from '@ioc:Adonis/Core/Application' +import User from "../app/Models/User"; +import Env from "@ioc:Adonis/Core/Env"; export default class AppProvider { public static needsApplication = true @@ -11,7 +13,12 @@ export default class AppProvider { } public async boot () { - // IoC container is ready + await User.firstOrNew({ + email: Env.get('ADMIN_USER', 'admin@linkyjs.dev') + }, { + email: Env.get('ADMIN_USER', 'admin@linkyjs.dev'), + password: Env.get('ADMIN_PASSWORD', 'password') + }) } public async ready () {