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 home page.
11///
12/// A placeholder until Milestone 2 makes `/{owner}` the real one, but enough to prove
13/// the identity flow end to end.
14///
15/// Reads through the same `describe_identity` use case that `/api/me` uses — which is
16/// the point of keeping it in the application layer rather than querying here.
17#[page("/")]
18async fn home(cx: &Cx) -> Result {
19 if !claimed(cx).await? {
20 return Err(redirect("/auth/setup").into());
21 }
22
23 view! {
24 <h1>"steid"</h1>
25 (match identity(cx).await? {
26 Some(identity) => view! {
27 <p>"Signed in as " <strong>(identity.handle.as_str())</strong></p>
28 <p>(identity.email.as_str())</p>
29 <form method="post" action="/auth/logout">
30 <button type="submit">"Sign out"</button>
31 </form>
32 },
33 None => view! {
34 <p>"Not signed in."</p>
35 <p><a href="/auth/login">"Sign in"</a></p>
36 },
37 }?)
38 }
39}