9362a10
ZhenYi
refactor: remove OAuth-related modules and update references for identity service integration
9362a10
use actix_web::http::header::{HeaderMap, HeaderValue, SET_COOKIE};
use export::http::{Redirect, Response};
pub fn read_cookie_header<'a>(headers: &'a HeaderMap, name: &str) -> Option<&'a str> {
let value = headers
.get(actix_web::http::header::COOKIE)?
.to_str()
.ok()?;
token::read_cookie(value, name)
}
pub fn append_cookie(response: &mut Response, cookie: &str) {
if let Ok(value) = HeaderValue::from_str(cookie) {
response.headers_mut().append(SET_COOKIE, value);
}
}
pub fn redirect_with_cookies(location: &str, cookies: &[String]) -> Response {
let mut response = Redirect::to(location).into_response();
for cookie in cookies {
append_cookie(&mut response, cookie);
}
response
}