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:
Evan Schwartz
2022-03-31 10:03:06 +02:00
committed by GitHub
co-authored by David Pedersen
parent 79501afd10
commit 3084dc10ca
5 changed files with 20 additions and 47 deletions
+5 -5
View File
@@ -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()
}
}