summaryrefslogtreecommitdiffstats
path: root/src/http/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/mod.rs')
-rw-r--r--src/http/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 07024d8..24da43f 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -238,7 +238,12 @@ fn dispatch(state: &State, req: &Req) -> Res {
// through a sid that a successful login marked authenticated.
let (sid, new_session) = match req.cookie("sid") {
Some(s) if auth::is_valid_session(&s) => (s, false),
- _ => (auth::new_session(), true),
+ _ => match auth::new_session() {
+ Some(s) => (s, true),
+ // No system RNG means no unguessable session id. Refuse rather than
+ // hand out a token someone else could compute.
+ None => return Res::text(500, "500: could not mint a session\n".into()),
+ },
};
let gated = routes::gate(state, req, &sid);
if let Some(mut res) = gated {