diff --git a/.gitignore b/.gitignore index d10dd28..61ab54a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ test.db db.sh +live-db-migrate.sh diff --git a/.woodpecker/deplyoment.yaml b/.woodpecker/deplyoment.yaml index cd3f588..010ec27 100644 --- a/.woodpecker/deplyoment.yaml +++ b/.woodpecker/deplyoment.yaml @@ -19,10 +19,16 @@ steps: SCW_ACCESS_KEY: from_secret: scw_access_key USERSTORE_SQLITE_PATH: - from_secret: userstore_sqlite_path + from_secret: userstore_sqlite_path2 + SMTP_PASSWORD: + from_secret: smtp_password + SMTP_USERNAME: + from_secret: smtp_username commands: - cd resources/infra - terraform init - sed -i 's@git.keks.cloud/kekskurse/miniauth:latest@git.keks.cloud/kekskurse/miniauth:${CI_COMMIT_SHA}@g' scw-container.tf - sed -i s@USERSTORE_SQLITE_PATH_SED@$USERSTORE_SQLITE_PATH@g scw-container.tf + - sed -i s@SMTP_USERNAME_SED@$SMTP_USERNAME@g scw-container.tf + - sed -i s@SMTP_PASSWORD_SED@$SMTP_PASSWORD@g scw-container.tf - terraform apply -auto-approve diff --git a/pkg/userstore/migrations/schema.sql b/pkg/userstore/migrations/schema.sql index a4b5a31..23e064b 100644 --- a/pkg/userstore/migrations/schema.sql +++ b/pkg/userstore/migrations/schema.sql @@ -1,26 +1,9 @@ -- --- Sqlite SQL Schema dump automatic generated by geni +-- LibSQL SQL Schema dump automatic generated by geni -- -CREATE TABLE schema_migrations (id VARCHAR(255) PRIMARY KEY); -CREATE TABLE users ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, - username TEXT NOT NULL UNIQUE, - password TEXT NOT NULL -); +CREATE TABLE schema_migrations (id VARCHAR(255) NOT NULL PRIMARY KEY); +CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, username TEXT NOT NULL UNIQUE, password TEXT NOT NULL); CREATE TABLE sqlite_sequence(name,seq); -CREATE TABLE mail ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, - user_id INTEGER NOT NULL, - mail TEXT NOT NULL UNIQUE, - validation_code TEXT NOT NULL UNIQUE, - is_validated BOOLEAN NOT NULL DEFAULT 0, - is_primary BOOLEAN NOT NULL DEFAULT 0, - - FOREIGN KEY(user_id) REFERENCES users(id) -); \ No newline at end of file +CREATE TABLE mail (id INTEGER PRIMARY KEY AUTOINCREMENT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, user_id INTEGER NOT NULL, mail TEXT NOT NULL UNIQUE, validation_code TEXT NOT NULL UNIQUE, is_validated BOOLEAN NOT NULL DEFAULT 0, is_primary BOOLEAN NOT NULL DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users (id)); \ No newline at end of file diff --git a/resources/infra/scw-container.tf b/resources/infra/scw-container.tf index d40eaee..266b4eb 100644 --- a/resources/infra/scw-container.tf +++ b/resources/infra/scw-container.tf @@ -23,8 +23,12 @@ resource "scaleway_container" "main" { environment_variables = { "WEB_PUBLIC_REGISTRATION" = "1" + "SMTP_SERVER" = "smtp.tem.scw.cloud" + "SMTP_FROM" = "auth@gutes.team" } secret_environment_variables = { "USERSTORE_SQLITE_PATH" = "USERSTORE_SQLITE_PATH_SED" + "SMTP_USERNAME" = "SMTP_USERNAME_SED" + "SMTP_PASSWORD" = "SMTP_PASSWORD_SED" } } diff --git a/templates/register.html b/templates/register.html index ab01512..ba6ac70 100644 --- a/templates/register.html +++ b/templates/register.html @@ -9,9 +9,11 @@ <body class="bg-gray-100 flex items-center justify-center min-h-screen"> <div class="bg-white p-8 shadow-xl w-full max-w-md"> <h2 class="text-2xl font-semibold text-gray-900 text-center mb-6">Registrieren</h2> + {{ if msg }} <div id="global-error" class=" bg-red-100 text-red-700 p-3 text-center mb-4 border border-red-400"> {{ .msg }} </div> + {{ end }} <form action="#" method="POST" class="space-y-4"> <div> <label for="username" class="block text-sm font-medium text-gray-700">Benutzername</label>