steid

@jamesgill /

1use topcoat::{
2 Result,
3 context::Cx,
4 router::{error::redirect, page},
5 view::view,
6};
7
8use super::context::{claimed, identity};
9
10/// The root.
11///
12/// Unclaimed, it sends you to `/auth/setup`. Claimed and signed in, it forwards to your
13/// own profile — the profile is the product, so the root is a signpost rather than a
14/// page. Claimed and signed out, it offers a way in; a multi-user instance will want
15/// something better here, but there is nothing to index yet.
16#[page("/")]
17async fn home(cx: &Cx) -> Result {
18 if !claimed(cx).await? {
19 return Err(redirect("/auth/setup").into());
20 }
21
22 if let Some(identity) = identity(cx).await? {
23 return Err(redirect(&format!("/{}", identity.handle)).into());
24 }
25
26 view! {
27 <h1>"steid"</h1>
28 <p><a href="/auth/login">"Sign in"</a></p>
29 }
30}