-
Notifications
You must be signed in to change notification settings - Fork 7
Store as document fix and documentation on how to configure session expiry. #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/lib.rs
Outdated
None => Ok(None), | ||
Some(doc) => Ok(Some(serde_json::from_str(doc.get_str("session")?)?)), | ||
Some(doc) => Ok(Some( | ||
bson::from_bson::<Session>(doc.get("session").unwrap().clone()).unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably should be ? instead of unwrap — if something goes wrong with the data state we wouldn't want to panic the server
Cargo.toml
Outdated
async-session = "2.0.0" | ||
async-trait = "0.1.36" | ||
serde_json = "1.0.56" | ||
chrono = "0.4.19" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async-session reexports chrono, so this dependency is unnecessary
src/lib.rs
Outdated
|
||
use async_session::{Result, Session, SessionStore}; | ||
use async_trait::async_trait; | ||
use chrono::Utc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use chrono::Utc; | |
use async_session::chrono::Utc; |
Thanks @jbr I've removed the external chrono link as you suggested. |
@No9 I don't think building a new session is ever in the responsibilities of a session store. If it can't parse a session from the stored record, that should probably be an Err with some sort of synthetic error that describes the problem |
Hey @jbr |
Thanks very much for the work on this @pepoviola - I like where this has landed with a simple session object that can be inlined with in the SessionMiddleware creation but also provides advanced options available.
Closing as this was integrated into #11 |
This patch fixes #6 and also exposes a datetime property named
created
at the root level of the session document as using the expiry property inside the session store object gives this error.It also provides instructions on how to configure mongo to expire the session.