fix: session cookie not saving
This commit is contained in:
@@ -74,6 +74,7 @@ impl HttpServer {
|
|||||||
"/api/stream-key",
|
"/api/stream-key",
|
||||||
post(create_stream_key_handler).get(get_all_stream_keys),
|
post(create_stream_key_handler).get(get_all_stream_keys),
|
||||||
)
|
)
|
||||||
|
// .route("/api/admin/server_stats", get(todo!()))
|
||||||
.route("/api/whip", post(handle_whip_injest))
|
.route("/api/whip", post(handle_whip_injest))
|
||||||
.route("/api/login", post(login_handler))
|
.route("/api/login", post(login_handler))
|
||||||
.route("/api/stream/{slug}", post(stream_handler))
|
.route("/api/stream/{slug}", post(stream_handler))
|
||||||
@@ -184,11 +185,20 @@ async fn create_stream_key_handler(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.len();
|
.len();
|
||||||
if payload.label.is_empty() || payload.label.len() > MAX_LABEL_LEN {
|
if payload.label.is_empty() || payload.label.len() > MAX_LABEL_LEN {
|
||||||
warn!(user_id = auth.0.id, label_len = payload.label.len(), max = MAX_LABEL_LEN, "stream key creation rejected: label length invalid");
|
warn!(
|
||||||
|
user_id = auth.0.id,
|
||||||
|
label_len = payload.label.len(),
|
||||||
|
max = MAX_LABEL_LEN,
|
||||||
|
"stream key creation rejected: label length invalid"
|
||||||
|
);
|
||||||
return StatusCode::UNPROCESSABLE_ENTITY;
|
return StatusCode::UNPROCESSABLE_ENTITY;
|
||||||
}
|
}
|
||||||
if key_amount >= auth.0.stream_key_limit.try_into().unwrap() {
|
if key_amount >= auth.0.stream_key_limit.try_into().unwrap() {
|
||||||
warn!(user_id = auth.0.id, limit = auth.0.stream_key_limit, "stream key limit reached");
|
warn!(
|
||||||
|
user_id = auth.0.id,
|
||||||
|
limit = auth.0.stream_key_limit,
|
||||||
|
"stream key limit reached"
|
||||||
|
);
|
||||||
return StatusCode::NOT_ACCEPTABLE;
|
return StatusCode::NOT_ACCEPTABLE;
|
||||||
}
|
}
|
||||||
let key = stream_key::Entity::create(&state.db, auth.0.id, value, payload.label, false).await;
|
let key = stream_key::Entity::create(&state.db, auth.0.id, value, payload.label, false).await;
|
||||||
@@ -255,7 +265,7 @@ async fn login_handler(
|
|||||||
let mut meow = Response::new("".to_string());
|
let mut meow = Response::new("".to_string());
|
||||||
meow.headers_mut().insert(
|
meow.headers_mut().insert(
|
||||||
SET_COOKIE,
|
SET_COOKIE,
|
||||||
format!("session={token}; HttpOnly; SameSite=Strict; Path=/")
|
format!("session={token}; SameSite=Strict; Path=/; Max-Age=2592000")
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user