fix issue for when it always redirect s
This commit is contained in:
parent
cbe4a4e653
commit
fa2999e1a8
1 changed files with 36 additions and 20 deletions
|
@ -183,12 +183,10 @@ pub async fn handle_callback(
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let redirect_target = match &query.state {
|
if let Some(redirect_url) = &query.state {
|
||||||
Some(s) => urlencoding::decode(s)
|
let redirect_target = urlencoding::decode(redirect_url)
|
||||||
.map(|s| s.into_owned())
|
.map(|s| s.into_owned())
|
||||||
.unwrap_or("/".to_string()),
|
.unwrap_or("/".to_string());
|
||||||
None => "/".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
headers.insert(
|
headers.insert(
|
||||||
|
@ -206,6 +204,24 @@ pub async fn handle_callback(
|
||||||
);
|
);
|
||||||
|
|
||||||
(StatusCode::FOUND, headers).into_response()
|
(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 {
|
pub async fn me(State(state): State<AppState>, headers: HeaderMap) -> impl IntoResponse {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue