But now, this code won't work (the cookie is None):
async fn check_login(&self, cookie_jar: &CookieJar) -> Result<Json<String>> {
let auth = cookie_jar.private().get("Authorization");
if auth.is_none() {
let error_response = Response::builder()
.status(StatusCode::UNAUTHORIZED)
.body("Unauthorized")
.into();
return Err(Error::from_response(error_response));
}
let auth_cookie = auth.unwrap();
Ok(Json(auth_cookie.to_string()))
}
However, if I provide the key manually, it works.
let auth = cookie_jar.private_with_key(self.my_stored_key).get("Authorization"); // works fine
Am I doing something wrong, or is this a bug?
I would prefer, not having to inject the key into als services' constructor, but rather use the private jar from the extractor.
I am having some troubles retrieving the private value from a
CookieJar
. As far as I understand it, the correct way to use thePrivateCookieJar
is:CookieJarManager
middleware with a keyCookieJar
in the requestprivate()
methodNow, this works fine when setting the cookie. I controlled it and the cookie was set in the header.
and the endpoint:
But now, this code won't work (the cookie is
None
):However, if I provide the key manually, it works.
Am I doing something wrong, or is this a bug? I would prefer, not having to inject the key into als services' constructor, but rather use the private jar from the extractor.
Thanks Josef