refactor: Use Redirect::to instead of Redirect::temporary for all redirects.
This commit is contained in:
@@ -89,7 +89,7 @@ pub async fn add_user(
|
||||
.await
|
||||
.context("Failed to insert new user into database")?;
|
||||
|
||||
Ok(Redirect::temporary("/__dungeon").into_response())
|
||||
Ok(Redirect::to("/__dungeon").into_response())
|
||||
}
|
||||
|
||||
pub async fn delete_user(
|
||||
@@ -111,7 +111,7 @@ pub async fn delete_user(
|
||||
.await
|
||||
.context(format!("Failed to delete user with id {}", id))?;
|
||||
|
||||
Ok(Redirect::temporary("/__dungeon").into_response())
|
||||
Ok(Redirect::to("/__dungeon").into_response())
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -138,5 +138,5 @@ pub async fn change_password(
|
||||
.await
|
||||
.context(format!("Failed to update password for user with id {}", id))?;
|
||||
|
||||
Ok(Redirect::temporary("/__dungeon").into_response())
|
||||
Ok(Redirect::to("/__dungeon").into_response())
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ pub async fn setup_form(State(state): State<Arc<AppState>>) -> Result<Response,
|
||||
.context("Failed to check user count for setup form")?;
|
||||
|
||||
if count.0 > 0 {
|
||||
return Ok(Redirect::temporary("/__dungeon/login").into_response());
|
||||
return Ok(Redirect::to("/__dungeon/login").into_response());
|
||||
}
|
||||
|
||||
Ok(HtmlTemplate(SetupTemplate { error: None }).into_response())
|
||||
@@ -67,7 +67,7 @@ pub async fn setup_submit(
|
||||
.context("Failed to check user count for setup submit")?;
|
||||
|
||||
if count.0 > 0 {
|
||||
return Ok(Redirect::temporary("/__dungeon/login").into_response());
|
||||
return Ok(Redirect::to("/__dungeon/login").into_response());
|
||||
}
|
||||
|
||||
let hashed = hash(&payload.password, DEFAULT_COST).context("Failed to hash password")?;
|
||||
@@ -80,7 +80,7 @@ pub async fn setup_submit(
|
||||
.await
|
||||
.context("Failed to insert initial admin user")?;
|
||||
|
||||
Ok(Redirect::temporary("/__dungeon/login").into_response())
|
||||
Ok(Redirect::to("/__dungeon/login").into_response())
|
||||
}
|
||||
|
||||
pub async fn login_form() -> impl IntoResponse {
|
||||
@@ -119,7 +119,7 @@ pub async fn login_submit(
|
||||
|
||||
let mut cookie = Cookie::new("dungeon_session", session_id);
|
||||
cookie.set_path("/");
|
||||
return Ok((cookie_jar.add(cookie), Redirect::temporary("/__dungeon")).into_response());
|
||||
return Ok((cookie_jar.add(cookie), Redirect::to("/__dungeon")).into_response());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ pub async fn logout_submit(
|
||||
|
||||
Ok((
|
||||
cookie_jar.remove(remove_cookie),
|
||||
Redirect::temporary("/__dungeon/login"),
|
||||
Redirect::to("/__dungeon/login"),
|
||||
)
|
||||
.into_response())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user