Add login/logout
This commit is contained in:
1 parent
cde5e651a6
commit
9358dd39a1
5 files changed
+80
-6
No files matched your search
@@ -25,11 +25,17 @@ class Netig < Roda
|
||||
password_label "Mot de passe"
|
||||
login_button "Se connecter"
|
||||
|
||||
login_redirect "/temporary_page"
|
||||
login_return_to_requested_location? true
|
||||
|
||||
already_logged_in do
|
||||
request.redirect("/")
|
||||
end
|
||||
|
||||
logout_redirect "/"
|
||||
end
|
||||
|
||||
require_relative "routes/admin"
|
||||
require_relative "routes/contact"
|
||||
|
||||
route do |r|
|
||||
|
||||
+22
-4
@@ -227,20 +227,38 @@ summary:focus-visible {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.topbar > form {
|
||||
margin: 0 20px 0 auto;
|
||||
}
|
||||
|
||||
.topbar a.topbar__account {
|
||||
margin-left: auto;
|
||||
margin-right: 20px;
|
||||
padding: 8px 14px;
|
||||
border: 1px solid var(--color-accent);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.topbar a.topbar__account:hover {
|
||||
.topbar .topbar__account {
|
||||
display: inline-block;
|
||||
padding: 8px 14px;
|
||||
border: 1px solid var(--color-accent);
|
||||
background: transparent;
|
||||
color: var(--color-accent);
|
||||
font: inherit;
|
||||
line-height: normal;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.topbar .topbar__account:hover {
|
||||
background: var(--color-accent);
|
||||
color: var(--color-background);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.topbar button.topbar__account {
|
||||
appearance: none;
|
||||
border-radius: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.topbar img {
|
||||
display: block;
|
||||
width: 48px;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
class Netig
|
||||
hash_branch "admin" do |r|
|
||||
require_admin!(r)
|
||||
|
||||
@page_title = "Admin — NETig"
|
||||
@page_description = "Interface d'administration de NETig."
|
||||
@canonical_url = "https://netig.net/admin"
|
||||
|
||||
r.is do
|
||||
r.get do
|
||||
view "admin"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def require_admin!(r)
|
||||
rodauth.require_account
|
||||
|
||||
admin = DB[:members].where(
|
||||
account_id: rodauth.account_id,
|
||||
admin: true
|
||||
).get(:admin)
|
||||
|
||||
return if admin
|
||||
|
||||
r.halt [
|
||||
403,
|
||||
{ "Content-Type" => "text/plain; charset=utf-8" },
|
||||
["Accès interdit."]
|
||||
]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
<section class="page-section">
|
||||
<div class="content">
|
||||
<h1>Interface d'administration de NETig</h1>
|
||||
<p>Test</p>
|
||||
</div>
|
||||
</section>
|
||||
+12
-2
@@ -1,4 +1,3 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
@@ -40,7 +39,18 @@
|
||||
<a href="https://webmail.netig.net" target="_blank" rel="noopener noreferrer">NETmail ↗</a>
|
||||
<a href="https://cloud.netig.net" target="_blank" rel="noopener noreferrer">NETcloud ↗</a>
|
||||
<a href="https://git.netig.net" target="_blank" rel="noopener noreferrer">NETgit ↗</a>
|
||||
<a class="topbar__account" href="/login">Mon espace ➜</a>
|
||||
<% if rodauth.logged_in? %>
|
||||
<form method="post" action="<%= rodauth.logout_path %>">
|
||||
<%== rodauth.csrf_tag(rodauth.logout_path) %>
|
||||
<button class="topbar__account" type="submit">
|
||||
Déconnexion
|
||||
</button>
|
||||
</form>
|
||||
<% else %>
|
||||
<a class="topbar__account" href="<%= rodauth.login_path %>">
|
||||
Connexion ➜
|
||||
</a>
|
||||
<% end %>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in new issue
Block a user