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