steam login

This commit is contained in:
Robin Appelman 2023-04-09 15:33:31 +02:00
commit fc5cd1d24f
12 changed files with 926 additions and 70 deletions

View file

@ -4,6 +4,7 @@ pub mod index;
mod plugin_section;
use crate::asset::saved_asset_url;
use crate::session::SessionData;
use maud::{html, Markup, DOCTYPE};
use std::borrow::Cow;
@ -12,7 +13,7 @@ pub trait Page {
fn render(&self) -> Markup;
}
pub fn render<T: Page>(page: T) -> Markup {
pub fn render<T: Page>(page: T, session: SessionData) -> Markup {
let style_url = saved_asset_url!("style.css");
html! {
(DOCTYPE)
@ -30,7 +31,13 @@ pub fn render<T: Page>(page: T) -> Markup {
span { a href = "/about" { "about" } }
span { a href = "/viewer" { "viewer" } }
span.beta { a href = "/editor" { "editor" } }
span.right { a.steam-login href = "/login" { "Sign in through Steam" } }
@if let SessionData::Authenticated(user) = session {
span.right { a href = "/logout" { "Logout" } }
span.right { a href = "/upload" { "Upload" } }
span.right { a href = (user.steam_id.profile_link()) { (user.name) } }
} @else {
span.right { a.steam-login href = "/login" { "Sign in through Steam" } }
}
}
.page { (page.render()) }
}