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 | |
40ab5c7feat: /api/me and a shared identity read model1mo | 8 | use super::context::{claimed, identity}; |
14223e7feat: claim, sign in, and sign out through the browser1mo | 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
40ab5c7feat: /api/me and a shared identity read model1mo | 14 | |
| 15 | |
| 16 | |
14223e7feat: claim, sign in, and sign out through the browser1mo | 17 | #[page("/")] |
| 18 | async fn home(cx: &Cx) -> Result { |
| 19 | if !claimed(cx).await? { |
| 20 | return Err(redirect("/setup").into()); |
| 21 | } |
| 22 | |
| 23 | view! { |
| 24 | <h1>"steid"</h1> |
40ab5c7feat: /api/me and a shared identity read model1mo | 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> |
14223e7feat: claim, sign in, and sign out through the browser1mo | 29 | <form method="post" action="/logout"> |
| 30 | <button type="submit">"Sign out"</button> |
| 31 | </form> |
| 32 | }, |
40ab5c7feat: /api/me and a shared identity read model1mo | 33 | None => view! { |
14223e7feat: claim, sign in, and sign out through the browser1mo | 34 | <p>"Not signed in."</p> |
| 35 | <p><a href="/login">"Sign in"</a></p> |
| 36 | }, |
| 37 | }?) |
| 38 | } |
| 39 | } |