setup: show flash
This commit is contained in:
parent
c670201b86
commit
cf9fb61f80
2 changed files with 18 additions and 8 deletions
|
|
@ -15,7 +15,6 @@ async fn setup_completed(_setup: CompletedSetup) -> Redirect {
|
|||
|
||||
#[get("/", rank = 2)]
|
||||
async fn setup(flash: Option<FlashMessage<'_>>) -> Template {
|
||||
// TODO: show flash on html page
|
||||
flash
|
||||
.map(|flash| Page::with_flash(Page::Setup, flash))
|
||||
.unwrap_or_else(|| Page::Setup.into())
|
||||
|
|
@ -37,13 +36,16 @@ async fn create_first_account(
|
|||
let form = form.into_inner();
|
||||
|
||||
// Parse url
|
||||
let url = match Url::parse(form.url) {
|
||||
Ok(url) => url,
|
||||
Err(e) => {
|
||||
return Ok(Either::Right(Flash::new(
|
||||
Redirect::to(uri!(self::setup)),
|
||||
FlashKind::Danger,
|
||||
"Failed to parse url".to_string(),
|
||||
e.to_string(),
|
||||
)));
|
||||
|
||||
let url = Url::parse(form.url).unwrap();
|
||||
}
|
||||
};
|
||||
|
||||
// Generate UserID
|
||||
let user_id = task::spawn_blocking(UserID::default).await?;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@
|
|||
<img src="http://localhost:8000/logo" height="96" alt="">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% if flash %}
|
||||
<div class="alert alert-{{flash.0}}" role="alert">
|
||||
<h4 class="alert-title">Could not finish setup</h4>
|
||||
<div class="text-muted">{{ flash.1 }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="/setup" method="post">
|
||||
<div class="card card-md">
|
||||
<div class="card-body text-center py-4 p-sm-5">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue