steid

@jamesgill /

1use topcoat::{
2 Result,
3 context::Cx,
4 router::{error::redirect, page},
5 view::view,
6};
7
8use crate::domain::Actor;
9
10use super::context::{claimed, current_actor};
11
12/// The home page.
13///
14/// A placeholder until Milestone 2 makes `/{owner}` the real one, but enough to prove
15/// the identity flow end to end.
16#[page("/")]
17async fn home(cx: &Cx) -> Result {
18 if !claimed(cx).await? {
19 return Err(redirect("/setup").into());
20 }
21
22 let actor = current_actor(cx).await?;
23
24 view! {
25 <h1>"steid"</h1>
26 (match &actor {
27 Actor::User(id) => view! {
28 <p>"Signed in as " <code>(id.as_str())</code></p>
29 <form method="post" action="/logout">
30 <button type="submit">"Sign out"</button>
31 </form>
32 },
33 Actor::Anonymous => view! {
34 <p>"Not signed in."</p>
35 <p><a href="/login">"Sign in"</a></p>
36 },
37 }?)
38 }
39}