14223e7feat: claim, sign in, and sign out through the browser1mo | 1 | use topcoat::{ |
| 2 | Result, |
| 3 | context::Cx, |
| 4 | router::{error::redirect, page}, |
| 5 | view::view, |
| 6 | }; |
| 7 | |
8ed4e5afeat: the root is the owner's profile1d | 8 | use crate::application::sole_owner_handle; |
| 9 | |
5d3dfa5feat: a global top bar, and pages choose their own width23h | 10 | use super::{ |
| 11 | context::{claimed, identity, orgs, server_error, users}, |
| 12 | layout::narrow, |
| 13 | }; |
14223e7feat: claim, sign in, and sign out through the browser1mo | 14 | |
a69e380feat: public profile page at /{handle}1mo | 15 | |
14223e7feat: claim, sign in, and sign out through the browser1mo | 16 | |
8ed4e5afeat: the root is the owner's profile1d | 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
14223e7feat: claim, sign in, and sign out through the browser1mo | 28 | #[page("/")] |
| 29 | async fn home(cx: &Cx) -> Result { |
| 30 | if !claimed(cx).await? { |
aaefaabfeat: root handles, grouped routes, reserved-handle denylist1mo | 31 | return Err(redirect("/auth/setup").into()); |
14223e7feat: claim, sign in, and sign out through the browser1mo | 32 | } |
| 33 | |
a69e380feat: public profile page at /{handle}1mo | 34 | if let Some(identity) = identity(cx).await? { |
| 35 | return Err(redirect(&format!("/{}", identity.handle)).into()); |
| 36 | } |
| 37 | |
8ed4e5afeat: the root is the owner's profile1d | 38 | if let Some(owner) = sole_owner_handle(&users(cx), &orgs(cx)) |
| 39 | .await |
| 40 | .map_err(server_error)? |
| 41 | { |
| 42 | return Err(redirect(&format!("/{owner}")).into()); |
| 43 | } |
| 44 | |
14223e7feat: claim, sign in, and sign out through the browser1mo | 45 | view! { |
5d3dfa5feat: a global top bar, and pages choose their own width23h | 46 | narrow( |
| 47 | <h1>"steid"</h1> |
| 48 | <p><a href="/auth/login">"Sign in"</a></p> |
| 49 | ) |
14223e7feat: claim, sign in, and sign out through the browser1mo | 50 | } |
| 51 | } |