Skip to content

Commit 02db622

Browse files
committed
Expire registration sessions after an hour
1 parent 5851584 commit 02db622

File tree

1 file changed

+9
-0
lines changed
  • crates/handlers/src/views/register/steps

1 file changed

+9
-0
lines changed

crates/handlers/src/views/register/steps/finish.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use axum::{
99
response::IntoResponse,
1010
};
1111
use axum_extra::TypedHeader;
12+
use chrono::Duration;
1213
use mas_axum_utils::{cookies::CookieJar, FancyError, SessionInfoExt as _};
1314
use mas_data_model::UserAgent;
1415
use mas_router::{PostAuthAction, UrlBuilder};
@@ -60,6 +61,14 @@ pub(crate) async fn get(
6061
));
6162
}
6263

64+
// Make sure the registration session hasn't expired
65+
// XXX: this duration is hard-coded, could be configurable
66+
if clock.now() - registration.created_at > Duration::hours(1) {
67+
return Err(FancyError::from(anyhow::anyhow!(
68+
"Registration session has expired"
69+
)));
70+
}
71+
6372
// Check that this registration belongs to this browser
6473
let registrations = UserRegistrationSessions::load(&cookie_jar);
6574
if !registrations.contains(&registration) {

0 commit comments

Comments
 (0)