Add login view

This commit is contained in:
paul 2019-08-22 00:48:27 +02:00
commit 63b1cf1c3f
9 changed files with 687 additions and 2 deletions
assets

View file

@ -0,0 +1,4 @@
DROP TABLE "reset";
DROP TABLE "confirmation";
DROP TABLE "email";
DROP TABLE "user";

View file

@ -0,0 +1,37 @@
CREATE TABLE "user" (
"id" bigserial NOT NULL,
"is_admin" boolean NOT NULL DEFAULT false,
"password" bytea NULL,
"created_at" timestamptz NOT NULL DEFAULT NOW(),
PRIMARY KEY ("id")
);
CREATE TABLE "email" (
"address" text NOT NULL,
"user_id" bigint NOT NULL,
"created_at" timestamptz NOT NULL DEFAULT NOW(),
FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE,
PRIMARY KEY ("address")
);
CREATE INDEX ON "email" ("user_id");
CREATE TABLE "confirmation" (
"email_address" text NOT NULL,
"user_id" bigint NOT NULL,
"selector" text NOT NULL,
"verifier" bytea NOT NULL, -- hashed
"expires_at" timestamptz NOT NULL DEFAULT NOW(),
FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE,
PRIMARY KEY ("selector")
);
CREATE INDEX ON "confirmation" ("user_id");
CREATE TABLE "reset" (
"user_id" bigint NOT NULL,
"selector" text NOT NULL,
"verifier" bytea NOT NULL, -- hashed
"expires_at" timestamptz NOT NULL DEFAULT NOW(),
FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE,
PRIMARY KEY ("selector")
);
CREATE UNIQUE INDEX ON "reset" ("user_id");

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Landing Page</title>
</head>
<body>
<h1>Login</h1>
{{- range .Errors }}
<p class="is-error">{{ . }}</p>
{{- end }}
<form action="/login" method="post">
<input type="email" name="login" required>
<input type="password" name="password" required>
{{ .csrfField }}
<input type="submit" value="Log In">
</form>
</body>
</html>