From e43313210269b8e48fe35b17ac416c9ba88ae4f3 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 18 Aug 2024 00:30:15 +0300 Subject: feat: logins!! yes you can finally sign in this is also supposed to show private posts intended for you! maybe i can also reveal my email to those who sign in! :3 --- templates/src/templates.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'templates/src/templates.rs') diff --git a/templates/src/templates.rs b/templates/src/templates.rs index 4f7970c..3d22eac 100644 --- a/templates/src/templates.rs +++ b/templates/src/templates.rs @@ -1,10 +1,9 @@ use http::StatusCode; use kittybox_util::MicropubChannel; - use crate::{Feed, VCard}; markup::define! { - Template<'a>(title: &'a str, blog_name: &'a str, feeds: Vec, user: Option, content: String) { + Template<'a>(title: &'a str, blog_name: &'a str, feeds: Vec, user: Option<&'a kittybox_indieauth::ProfileUrl>, content: String) { @markup::doctype() html { head { @@ -41,12 +40,18 @@ markup::define! { li { a[href=&feed.uid] { @feed.name } } } li.shiftright { - @if user.is_none() { - a #login[href="/login/start"] { "Sign in" } - } else { + @if let Some(user) = &user { span { - @user.as_ref().unwrap() " - " a #logout[href="/logout"] { "Sign out" } + @if let Some(kittybox_indieauth::Profile { name: Some(name), photo, .. }) = &user.profile { + a[href=user.me.as_str()] { @name } + } else { + @user.me.as_str() + } + " - " + a #logout[href="/.kittybox/login/logout"] { "Sign out" } } + } else { + a #login[href="/.kittybox/login/start"] { "Sign in" } } } } -- cgit 1.4.1