Skip to content
Snippets Groups Projects
Verified Commit fa2999e1 authored by creations's avatar creations :earth_africa:
Browse files

fix issue for when it always redirect s

parent cbe4a4e6
No related branches found
No related tags found
No related merge requests found
......@@ -183,12 +183,10 @@ pub async fn handle_callback(
)
.await;
let redirect_target = match &query.state {
Some(s) => urlencoding::decode(s)
if let Some(redirect_url) = &query.state {
let redirect_target = urlencoding::decode(redirect_url)
.map(|s| s.into_owned())
.unwrap_or("/".to_string()),
None => "/".to_string(),
};
.unwrap_or("/".to_string());
let mut headers = HeaderMap::new();
headers.insert(
......@@ -206,6 +204,24 @@ pub async fn handle_callback(
);
(StatusCode::FOUND, headers).into_response()
} else {
let mut headers = HeaderMap::new();
headers.insert(
"Set-Cookie",
format!(
"session={}; Max-Age=3600; Path=/; SameSite=None; Secure; HttpOnly",
session_id
)
.parse()
.unwrap(),
);
let response = AuthResponse {
user,
session: session_id,
};
(StatusCode::OK, headers, Json(response)).into_response()
}
}
pub async fn me(State(state): State<AppState>, headers: HeaderMap) -> impl IntoResponse {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment