authenticate session if disable_auth env var is true

This commit is contained in:
2022-03-24 09:43:25 +02:00
parent 979ec4eb64
commit c65f568e40

View File

@ -79,11 +79,16 @@ fn main() {
// assign a unique id to each client (appends a cookie to the response // assign a unique id to each client (appends a cookie to the response
// with a name of "SID" and a duration of one hour (3600 seconds) // with a name of "SID" and a duration of one hour (3600 seconds)
rouille::session::session(request, "SID", 3600, |session| { rouille::session::session(request, "SID", 3600, |session| {
// if the "DISABLE_AUTH" env var is true, authenticate the session
let mut session_data = if CONFIG.disable_auth {
Some(SessionData {
_login: "success".to_string(),
})
// if the client already has an identifier from a previous request, // if the client already has an identifier from a previous request,
// try to load the existing session data. if successful, make a // try to load the existing session data. if successful, make a
// copy of the data in order to avoid locking the session for too // copy of the data in order to avoid locking the session for too
// long // long
let mut session_data = if session.client_has_sid() { } else if session.client_has_sid() {
sessions_storage.lock().unwrap().get(session.id()).cloned() sessions_storage.lock().unwrap().get(session.id()).cloned()
} else { } else {
None None