mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-24 00:00:16 +02:00
Accept &str for Redirect (#889)
* Accept &str for Redirect * Fix doc example * fix more docs examples * update changelog * fix changelog label Co-authored-by: David Pedersen <[email protected]>
This commit is contained in:
co-authored by
David Pedersen
parent
79501afd10
commit
3084dc10ca
@@ -120,7 +120,7 @@ async fn discord_auth(Extension(client): Extension<BasicClient>) -> impl IntoRes
|
||||
.url();
|
||||
|
||||
// Redirect to Discord's oauth service
|
||||
Redirect::to(auth_url.to_string().parse().unwrap())
|
||||
Redirect::to(&auth_url.to_string())
|
||||
}
|
||||
|
||||
// Valid user session required. If there is none, redirect to the auth page
|
||||
@@ -139,12 +139,12 @@ async fn logout(
|
||||
let session = match store.load_session(cookie.to_string()).await.unwrap() {
|
||||
Some(s) => s,
|
||||
// No session active, just redirect
|
||||
None => return Redirect::to("/".parse().unwrap()),
|
||||
None => return Redirect::to("/"),
|
||||
};
|
||||
|
||||
store.destroy_session(session).await.unwrap();
|
||||
|
||||
Redirect::to("/".parse().unwrap())
|
||||
Redirect::to("/")
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -193,14 +193,14 @@ async fn login_authorized(
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert(SET_COOKIE, cookie.parse().unwrap());
|
||||
|
||||
(headers, Redirect::to("/".parse().unwrap()))
|
||||
(headers, Redirect::to("/"))
|
||||
}
|
||||
|
||||
struct AuthRedirect;
|
||||
|
||||
impl IntoResponse for AuthRedirect {
|
||||
fn into_response(self) -> Response {
|
||||
Redirect::temporary("/auth/discord".parse().unwrap()).into_response()
|
||||
Redirect::temporary("/auth/discord").into_response()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user