steid

@jamesgill /

1use topcoat::{
2 Result,
3 context::Cx,
4 router::{error::redirect, page},
5 view::view,
6};
7
8use super::{context::claimed, layout::narrow, org::home};
9
10/// The root.
11///
12/// An instance belongs to one owner, so the root is a signpost rather than a page of
13/// its own. Unclaimed, it sends you to `/auth/setup`. Otherwise it forwards to the
14/// **home page** — the organisation the instance is for, which is a company or a
15/// person, chosen in the setup wizard and changeable at `/{handle}/settings`.
16///
17/// **The same place for everyone**, signed in or not. It used to send a signed-in
18/// visitor to their own profile, which was right while an instance was one person and
19/// wrong the moment it is a company: a member landing on themselves rather than on
20/// their employer's repositories is the front door pointing somewhere private. Your own
21/// page is a click away in the header; the instance's is what the URL means.
22///
23/// Where nobody has chosen, [`home_handle`](crate::application::home_handle) falls back
24/// to the sole owner's handle, so an instance that upgraded into this keeps exactly the
25/// front door it had. Only a multi-user instance that never chose has no answer, and it
26/// gets the generic landing rather than an elected one.
27#[page("/")]
28async fn home_page(cx: &Cx) -> Result {
29 if !claimed(cx).await? {
30 return Err(redirect("/auth/setup").into());
31 }
32
33 if let Some(handle) = home(cx).await? {
34 return Err(redirect(&format!("/{handle}")).into());
35 }
36
37 view! {
38 narrow(
39 <h1>"steid"</h1>
40 <p><a href="/auth/login">"Sign in"</a></p>
41 )
42 }
43}