Convert templates to pongo2

This commit is contained in:
William Bouzourène 2024-12-22 15:17:05 +01:00
parent 266cd2f4d2
commit d61e607b8a
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww
22 changed files with 311 additions and 136 deletions

12
.vscode/settings.json vendored
View file

@ -1,5 +1,11 @@
{
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": false
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"files.associations": {
"*.html": "twig"
},
"emmet.includeLanguages": {
"twig": "html"
},
}

View file

@ -6,5 +6,5 @@ func Homepage(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{
"PageTitle": "Accueil",
"Title": "Hello, World!",
}, "layouts/main")
})
}

View file

@ -14,7 +14,7 @@ import (
func LoginForm(c *fiber.Ctx) error {
return c.Render("login", fiber.Map{
"PageTitle": "Connexion",
}, "layouts/main")
})
}
func LoginProcess(c *fiber.Ctx) error {
@ -50,7 +50,7 @@ func LoginProcess(c *fiber.Ctx) error {
return c.Render("login", fiber.Map{
"PageTitle": "Connexion",
"LoginError": "Email ou mot de passe incorrect",
}, "layouts/main")
})
}
sess.Set("userid", user.ID)

View file

@ -75,5 +75,5 @@ func TotpEnrollPage(c *fiber.Ctx) error {
"PageTitle": "Enregistrement multifacteur",
"QrCode": imgBase64,
"Secret": key.Secret(),
}, "layouts/main")
})
}

View file

@ -2,7 +2,6 @@ package controllers
import (
"fmt"
"strings"
"git.readonly.ch/bouzoure/popvaud-people/helpers"
"git.readonly.ch/bouzoure/popvaud-people/models"
@ -109,6 +108,6 @@ func WelcomePage(c *fiber.Ctx) error {
"Email": user.Email,
"Name": user.Name,
"EmailUpdate": emailUpdate,
"FormErrors": strings.Join(formErrors, "<br>"),
}, "layouts/main")
"FormErrors": formErrors,
})
}

13
go.mod
View file

@ -4,6 +4,7 @@ go 1.23.4
require (
github.com/glebarez/sqlite v1.11.0
github.com/go-playground/validator v9.31.0+incompatible
github.com/gofiber/fiber/v2 v2.52.5
github.com/gofiber/storage/badger/v2 v2.0.1
github.com/gofiber/template/pug/v2 v2.1.7
@ -15,9 +16,11 @@ require (
)
require (
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/CloudyKit/jet/v6 v6.2.0 // indirect
github.com/Joker/hpp v1.0.0 // indirect
github.com/Joker/jade v1.1.3 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
@ -25,11 +28,13 @@ require (
github.com/dgraph-io/badger/v3 v3.2103.5 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/flosch/pongo2/v6 v6.0.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator v9.31.0+incompatible // indirect
github.com/gofiber/template v1.8.3 // indirect
github.com/gofiber/template/django/v3 v3.1.12 // indirect
github.com/gofiber/template/jet/v2 v2.1.10 // indirect
github.com/gofiber/utils v1.1.0 // indirect
github.com/gofiber/utils/v2 v2.0.0-beta.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
@ -39,6 +44,7 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/golobby/cast v1.3.3 // indirect
github.com/google/flatbuffers v23.5.26+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.17.2 // indirect
@ -54,10 +60,11 @@ require (
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect

24
go.sum
View file

@ -1,13 +1,17 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oME=
github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
github.com/Joker/hpp v1.0.0 h1:65+iuJYdRXv/XyN62C1uEmmOx3432rNG/rKlX6V7Kkc=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk=
github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
@ -41,6 +45,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/flosch/pongo2/v6 v6.0.0 h1:lsGru8IAzHgIAw6H2m4PCyleO58I40ow6apih0WprMU=
github.com/flosch/pongo2/v6 v6.0.0/go.mod h1:CuDpFm47R0uGGE7z13/tTlt1Y6zdxvr2RLT5LJhsHEU=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
@ -58,6 +64,10 @@ github.com/gofiber/storage/badger/v2 v2.0.1 h1:iIB5Dh2dypJjdEruYgBf7H4l5a98R5pVK
github.com/gofiber/storage/badger/v2 v2.0.1/go.mod h1:2LA5uR3q4xFVd0oXIZWK+7yzlO2vzLa/D062R7fowFI=
github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc=
github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
github.com/gofiber/template/django/v3 v3.1.12 h1:w2jxm9bJajhvrroXqEmUmakbvDSlzjpHgOI8yyh2iJs=
github.com/gofiber/template/django/v3 v3.1.12/go.mod h1:4YNpM+LJ/el+cjUpdulp8lOH6dxZ2jaQmrF4E2/KGAk=
github.com/gofiber/template/jet/v2 v2.1.10 h1:FRmpHeHAh0+H/eUdIKiEGzg3c93lCs29o73rKuHl/sI=
github.com/gofiber/template/jet/v2 v2.1.10/go.mod h1:QeUnwUkq/VAhbhSJZCNlgH4VxwPE4g3WqztzrP1oQJo=
github.com/gofiber/template/pug/v2 v2.1.7 h1:KFvCNq7huc8TLMcfCSxMljloqtiXOGmqzpKl4PaBUfk=
github.com/gofiber/template/pug/v2 v2.1.7/go.mod h1:9hAsWmaNUHOTTdG2+ITer100tGtICjzfL3yRCugW8hM=
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
@ -104,8 +114,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@ -215,8 +226,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -258,7 +269,6 @@ golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@ -288,6 +298,8 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

10
main.go
View file

@ -12,7 +12,7 @@ import (
"git.readonly.ch/bouzoure/popvaud-people/middlewares"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/template/pug/v2"
"github.com/gofiber/template/django/v3"
)
//go:embed static/*
@ -49,9 +49,9 @@ func main() {
}
// Create a new engine
var engine *pug.Engine
var engine *django.Engine
if config.Debug {
engine = pug.New("./views", ".pug")
engine = django.New("./views", ".html")
engine.ShouldReload = true
} else {
embedViews2, err := fs.Sub(embedViews, "views")
@ -59,9 +59,9 @@ func main() {
log.Fatal(err)
}
engine = pug.NewFileSystem(
engine = django.NewFileSystem(
http.FS(embedViews2),
".pug",
".html",
)
}

View file

@ -1,4 +0,0 @@
$(document).ready(function() {
var elem = $("#totp-enroll-image img");
$(elem).attr("src", $(elem).data("image"));
});

5
views/index.html Normal file
View file

@ -0,0 +1,5 @@
{% extends "layouts/main.html" %}
{% block main %}
<h1>Home</h1>
{% endblock %}

View file

@ -1,5 +0,0 @@
include partials/header.pug
h1 #{.Title}
include partials/footer.pug

38
views/layouts/main.html Normal file
View file

@ -0,0 +1,38 @@
<!doctype html>
<html lang="fr" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% set PageTitleSuffix = "Camarades | POP Vaud" %}
{% if PageTitle %}
<title>{{ PageTitle }} | {{ PageTitleSuffix }}</title>
{% else %}
<title>{{ PageTitleSuffix }}</title>
{% endif %}
<link rel="shortcut icon" href="/static/images/favicon.jpg" type="image/jpg">
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/main.css">
{% block stylesheet %}{% endblock %}
</head>
<body>
{% block header %}
{% include "partials/header.html" %}
{% endblock %}
{% block main %}
<!-- Content goes here -->
{% endblock %}
<script src="/static/jquery/jquery.min.js"></script>
<script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/static/feather/dist/feather.min.js"></script>
<script>
$(document).ready(function() {
feather.replace();
});
</script>
{% block javascript %}{% endblock %}
</body>
</html>

View file

@ -1,20 +0,0 @@
doctype html
html(lang="fr", data-bs-theme="dark")
head
if .PageTitle
title #{.PageTitle} - People - POP Vaud
else
title People - POP Vaud
meta(name="viewport" content="width=device-width, initial-scale=1")
link(rel="icon", href="/static/images/favicon.jpg")
link(rel="stylesheet", href="/static/bootstrap/css/bootstrap.min.css")
link(rel="stylesheet", href="/static/main.css")
body
| {{embed}}
script(src="/static/jquery/jquery.min.js")
script(src="/static/bootstrap/js/bootstrap.bundle.min.js")
script(src="/static/feather/dist/feather.min.js")
script feather.replace();
script(src="/static/events.js")

53
views/login.html Normal file
View file

@ -0,0 +1,53 @@
{% extends "layouts/main.html" %}
{% block main %}
<div class="container">
<div id="login-card" class="my-5">
<div class="card">
<div class="card-header">
Authentification
</div>
<div class="card-body">
{% if LoginError %}
<div class="alert alert-danger">
{{ LoginError }}
</div>
{% endif %}
<form id="login" method="post">
<div class="mb-3">
<label for="email" class="form-label">
Adresse email
</label>
<input
id="email"
class="form-control"
type="email"
name="email"
required
>
</div>
<div class="mb-3">
<label for="password" class="form-label">
Mot de passe
</label>
<input
id="password"
class="form-control"
type="password"
name="password"
required
>
</div>
<div class="text-end">
<button class="btn btn-primary" type="submit">
<i class="me-2" data-feather="log-in"></i>
Connexion
</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,22 +0,0 @@
include partials/header.pug
.container
#login-card.my-5
.card
.card-header
| Authentification
.card-body
if .LoginError
.alert.alert-danger
| #{.LoginError}
form#login(method="post")
.mb-3
label.form-label(for="email") Adresse email
input#email.form-control(type="email", required, name="email")
.mb-3
label.form-label(for="password") Mot de passe
input#password.form-control(type="password", required, name="password")
.mt-3.text-end
button.btn.btn-primary(type="submit")
i.me-2(data-feather="log-in")
| Connexion

View file

@ -1 +0,0 @@
h2 Footer

View file

@ -0,0 +1,13 @@
<nav class="navbar bg-body-tertiary">
<div class="container">
<a href="/" class="navbar-brand">
<img
id="header-logo"
class="me-1"
src="/static/images/logo.jpg"
alt="Logo"
>
Camarades
</a>
</div>
</nav>

View file

@ -1,5 +0,0 @@
nav.navbar.bg-body-tertiary
div.container
a.navbar-brand(href="/")
img#header-logo.me-1(src="/static/images/logo.jpg", alt="Logo")
| Gestion membres

60
views/totp_enroll.html Normal file
View file

@ -0,0 +1,60 @@
{% extends "layouts/main.html" %}
{% block main %}
<div class="container">
<div id="login-card" class="my-5">
<div class="card">
<div class="card-header">
Vérification multifacteur (TOTP)
</div>
<div class="card-body">
{% if MfaError %}
<div class="alert alert-danger">
{{ MfaError }}
</div>
{% endif %}
<div id="totp-enroll-image" class="text-center my-3">
<img src="{{ QrCode }}" alt="Code QR">
</div>
<form id="login" method="post">
<div class="mb-3">
<label for="secret" class="form-label">
Secret (si pas possible de scanner le code QR)
</label>
<input
id="secret"
class="form-control"
type="text"
name="secret"
disabled
value="{{ Secret }}"
>
</div>
<div class="mb-3">
<label for="otp" class="form-label">
Code temporaire
</label>
<input
id="otp"
class="form-control"
type="text"
name="otp"
required
placeholder="000000"
pattern="[0-9]{6}"
>
</div>
<div class="text-end">
<button class="btn btn-primary" type="submit">
<i class="me-2" data-feather="check-circle"></i>
Vérifier
</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,24 +0,0 @@
include partials/header.pug
.container
#login-card.my-5
.card
.card-header
| Vérification multifacteur (TOTP)
.card-body
if .MfaError
.alert.alert-danger
| #{.MfaError}
#totp-enroll-image.text-center.my-3
img(data-image=.QrCode)
form#login(method="post")
.mb-3
label.form-label(for="secret") Secret (si pas possible de scanner le code QR)
input#secret.form-control(type="text", value!=.Secret, disabled)
.mb-3
label.form-label(for="otp") Code temporaire
input#otp.form-control(type="text", required, name="otp", placeholder="000000" pattern="[0-9]{6}")
.mt-3.text-end
button.btn.btn-primary(type="submit")
i.me-2(data-feather="check-circle")
| Vérifier

94
views/welcome.html Normal file
View file

@ -0,0 +1,94 @@
{% extends "layouts/main.html" %}
{% block main %}
<div class="container">
<div id="login-card" class="my-5">
<div class="card">
<div class="card-header">
Paramètres du compte
</div>
<div class="card-body">
{% if FormErrors %}
<div class="alert alert-danger">
<ul class="mb-0">
{% for error in FormErrors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<form id="login" method="post">
<div class="mb-3">
<label for="email" class="form-label">
Adresse email
</label>
{% if EmailUpdate %}
<input
id="email"
class="form-control"
type="email"
name="email"
required
value="{{ Email }}"
>
{% else %}
<input
id="email"
class="form-control"
type="text"
name="email"
disabled
value="{{ Email }}"
>
{% endif %}
</div>
<div class="mb-3">
<label for="name" class="form-label">
Nom complet
</label>
<input
id="name"
class="form-control"
type="text"
name="name"
required
value="{{ Name }}"
>
</div>
<div class="mb-3">
<label for="password" class="form-label">
Nouveau mot de passe
</label>
<input
id="password"
class="form-control"
type="password"
name="password"
required
>
</div>
<div class="mb-3">
<label for="password-verify" class="form-label">
Vérifier le mot de passe
</label>
<input
id="password-verify"
class="form-control"
type="password"
name="password-verify"
required
>
</div>
<div class="text-end">
<button class="btn btn-primary" type="submit">
<i class="me-2" data-feather="save"></i>
Enregistrer
</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,31 +0,0 @@
include partials/header.pug
.container
#login-card.my-5
.card
.card-header
| Paramètres du compte
.card-body
if .FormErrors
.alert.alert-danger
| #{.FormErrors}
form#login(method="post")
.mb-3
label.form-label(for="email") Adresse email
if .EmailUpdate
input#email.form-control(type="email", required, name="email", value=.Email)
else
input#email.form-control(type="text", disabled, name="email", value=.Email)
.mb-3
label.form-label(for="name") Nom complet
input#name.form-control(type="text", required, name="name", value=.Name)
.mb-3
label.form-label(for="password") Nouveau mot de passe
input#password.form-control(type="password", required, name="password")
.mb-3
label.form-label(for="password-verify") Vérifier le mot de passe
input#password-verify.form-control(type="password", required, name="password-verify")
.mt-3.text-end
button.btn.btn-primary(type="submit")
i.me-2(data-feather="save")
| Enregistrer