1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-15 06:20:27 +00:00
mycorrhiza/views/auth.qtpl

151 lines
5.5 KiB
Plaintext
Raw Normal View History

{% import "net/http" %}
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
2021-09-06 17:46:34 +00:00
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
2020-11-14 10:39:18 +00:00
2022-03-20 21:24:40 +00:00
{% func Register(rq *http.Request) %}
2021-09-06 17:46:34 +00:00
{% code
lc := l18n.FromRequest(rq)
%}
<div class="layout">
<main class="main-width">
<section>
{% if cfg.AllowRegistration %}
<form class="modal" method="post" action="/register?{%s rq.URL.RawQuery %}" id="register-form" enctype="multipart/form-data" autocomplete="off">
<fieldset class="modal__fieldset">
2021-09-06 17:46:34 +00:00
<legend class="modal__title">{%s lc.Get("auth.register_header", &l18n.Replacements{"name": cfg.WikiName}) %}</legend>
2021-09-06 17:46:34 +00:00
<label for="register-form__username">{%s lc.Get("auth.username") %}</label>
<br>
<input type="text" required autofocus id="login-form__username" name="username">
<br>
2021-09-06 17:46:34 +00:00
<label for="login-form__password">{%s lc.Get("auth.password") %}</label>
<br>
<input type="password" required name="password">
2021-09-06 17:46:34 +00:00
<p>{%s lc.Get("auth.password_tip") %}</p>
<p>{%s lc.Get("auth.cookie_tip") %}</p>
<button class="btn" type="submit" value="Register">{%s lc.Get("auth.register_button") %}</button>
<a class="btn btn_weak" href="/{%s rq.URL.RawQuery %}">{%s lc.Get("ui.cancel") %}</a>
</fieldset>
</form>
2022-03-20 21:24:40 +00:00
{%= telegramWidget(lc) %}
{% elseif cfg.UseAuth %}
2021-09-06 17:46:34 +00:00
<p>{%s lc.Get("auth.noregister") %}</p>
<p><a href="/{%s rq.URL.RawQuery %}">← {%s lc.Get("auth.go_back") %}</a></p>
{% else %}
2021-09-06 17:46:34 +00:00
<p>{%s lc.Get("auth.noauth") %}</p>
<p><a href="/{%s rq.URL.RawQuery %}">← {%s lc.Get("auth.go_back") %}</a></p>
{% endif %}
</section>
</main>
</div>
{% endfunc %}
2022-03-20 21:24:40 +00:00
{% func Login(lc *l18n.Localizer) %}
2021-01-26 05:41:57 +00:00
<div class="layout">
<main class="main-width">
2020-11-14 10:39:18 +00:00
<section>
{% if cfg.UseAuth %}
<form class="modal" method="post" action="/login" id="login-form" enctype="multipart/form-data" autocomplete="on">
2021-02-23 14:36:12 +00:00
<fieldset class="modal__fieldset">
2021-09-06 17:46:34 +00:00
<legend class="modal__title">{%s lc.Get("auth.login_header", &l18n.Replacements{"name": cfg.WikiName}) %}</legend>
<label for="login-form__username">{%s lc.Get("auth.username") %}</label>
2021-02-23 14:36:12 +00:00
<br>
<input type="text" required autofocus id="login-form__username" name="username" autocomplete="username">
<br>
2021-09-06 17:46:34 +00:00
<label for="login-form__password">{%s lc.Get("auth.password") %}</label>
2021-02-23 14:36:12 +00:00
<br>
<input type="password" required name="password" autocomplete="current-password">
2021-09-06 17:46:34 +00:00
<p>{%s lc.Get("auth.cookie_tip") %}</p>
<button class="btn" type="submit" value="Log in">{%s lc.Get("auth.login_button") %}</button>
<a class="btn btn_weak" href="/">{%s lc.Get("ui.cancel") %}</a>
2020-11-14 10:39:18 +00:00
</fieldset>
</form>
2022-03-20 21:24:40 +00:00
{%= telegramWidget(lc) %}
2020-11-14 10:39:18 +00:00
{% else %}
2021-09-06 17:46:34 +00:00
<p>{%s lc.Get("auth.noauth") %}</p>
<p><a class="btn btn_weak" href="/">← {%s lc.Get("auth.go_home") %}</a></p>
2020-11-14 10:39:18 +00:00
{% endif %}
</section>
</main>
2021-01-26 05:41:57 +00:00
</div>
2020-11-14 10:39:18 +00:00
{% endfunc %}
2021-07-14 19:51:55 +00:00
Telegram auth widget was requested by Yogurt. As you can see, we don't offer user administrators control over it. Of course we don't.
2022-03-20 21:24:40 +00:00
{% func telegramWidget(lc *l18n.Localizer) %}
2021-07-14 19:51:55 +00:00
{% if cfg.TelegramEnabled %}
2021-09-06 17:46:34 +00:00
<p class="telegram-notice">{%s lc.Get("auth.telegram_tip") %}</p>
2021-07-14 19:51:55 +00:00
<script async src="https://telegram.org/js/telegram-widget.js?15" data-telegram-login="{%s cfg.TelegramBotName %}" data-size="medium" data-userpic="false" data-auth-url="{%s cfg.URL %}/telegram-login"></script>
{% endif %}
{% endfunc %}
2022-03-20 21:24:40 +00:00
{% func LoginError(err string, lc *l18n.Localizer) %}
2021-01-26 05:41:57 +00:00
<div class="layout">
<main class="main-width">
2020-11-14 10:39:18 +00:00
<section>
{% switch err %}
{% case "unknown username" %}
2021-09-06 17:46:34 +00:00
<p class="error">{%s lc.Get("auth.error_username") %}</p>
2020-11-14 10:39:18 +00:00
{% case "wrong password" %}
2021-09-06 17:46:34 +00:00
<p class="error">{%s lc.Get("auth.error_password") %}</p>
2020-11-14 10:39:18 +00:00
{% default %}
<p class="error">{%s err %}</p>
{% endswitch %}
2021-09-06 17:46:34 +00:00
<p><a href="/login">← {%s lc.Get("auth.try_again") %}</a></p>
2020-11-14 10:39:18 +00:00
</section>
</main>
2021-01-26 05:41:57 +00:00
</div>
2020-11-14 10:39:18 +00:00
{% endfunc %}
2022-03-20 21:24:40 +00:00
{% func Logout(can bool, lc *l18n.Localizer) %}
2021-01-26 05:41:57 +00:00
<div class="layout">
<main class="main-width">
2020-11-14 13:03:06 +00:00
<section>
{% if can %}
2021-09-06 17:46:34 +00:00
<h1>{%s lc.Get("auth.logout_header") %}</h1>
<form method="POST" action="/logout">
<input class="btn btn_accent" type="submit" value="{%s lc.Get("auth.logout_button") %}"/>
<a class="btn btn_weak" href="/">{%s lc.Get("auth.go_home") %}</a>
</form>
2020-11-14 13:03:06 +00:00
{% else %}
2021-09-06 17:46:34 +00:00
<p>{%s lc.Get("auth.logout_anon") %}</p>
<p><a href="/login">{%s lc.Get("auth.login_title") %}</a></p>
<p><a href="/">← {%s lc.Get("auth.go_home") %}</a></p>
2020-11-14 13:03:06 +00:00
{% endif %}
</section>
</main>
2021-01-26 05:41:57 +00:00
</div>
2020-11-14 13:03:06 +00:00
{% endfunc %}
2022-03-20 21:24:40 +00:00
{% func Lock(lc *l18n.Localizer) %}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2021-09-06 17:46:34 +00:00
<title>🔒 {%s lc.Get("auth.lock_title") %}</title>
<link rel="shortcut icon" href="/static/favicon.ico">
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<main class="locked-notice">
<section class="locked-notice__message">
<p class="locked-notice__lock">🔒</p>
2021-09-06 17:46:34 +00:00
<h1 class="locked-notice__title">{%s lc.Get("auth.lock_title") %}</h1>
<form class="locked-notice__login-form" method="post" action="/login" id="login-form" enctype="multipart/form-data" autocomplete="on">
2021-09-06 17:46:34 +00:00
<label for="login-form__username">{%s lc.Get("auth.username") %}</label>
2021-07-24 11:09:39 +00:00
<br>
<input type="text" required autofocus id="login-form__username" name="username" autocomplete="username">
<br>
2021-09-06 17:46:34 +00:00
<label for="login-form__password">{%s lc.Get("auth.password") %}</label>
2021-07-24 11:09:39 +00:00
<br>
<input type="password" required name="password" autocomplete="current-password">
<br>
2021-09-06 17:46:34 +00:00
<button class="btn" type="submit" value="Log in">{%s lc.Get("auth.login_button") %}</button>
2021-07-24 11:09:39 +00:00
</form>
2022-03-20 21:24:40 +00:00
{%= telegramWidget(lc) %}
</section>
</main>
</body>
</html>
2021-07-14 19:51:55 +00:00
{% endfunc %}