fn add_auth_cookie(
    settings: Arc<Settings>,
    auth_token: String,
    maybe_expires: Option<DateTime<Utc>>,
    response: response::Builder,
) -> response::Builder {
    let mut auth_cookie = cookie::Cookie::build(&settings.auth_cookie, auth_token)
        .http_only(true)
        .path(&settings.cookie_path)
        .secure(settings.cookie_secure);
    if let Some(cookie_domain) = &settings.cookie_domain {
        auth_cookie = auth_cookie.domain(cookie_domain);
    }
    if let Some(expires) = maybe_expires {
        let maxage = (expires - Utc::now()).num_seconds();
        if maxage > 0 {
            auth_cookie = auth_cookie.max_age(time::Duration::seconds(maxage));
        }
    }
    response.header(header::SET_COOKIE, auth_cookie.finish().to_string())
}
// Add a new auth cookie to the response
Add a new auth cookie to the response
Add a new auth cookie to the response
fn add_auth_cookie(
    settings: Arc<Settings>,
    auth_token: String,
    maybe_expires: Option<DateTime<Utc>>,
    response: response::Builder,
) -> response::Builder {
    let mut auth_cookie = cookie::Cookie::build(&settings.auth_cookie, auth_token)
        .http_only(true)
        .path(&settings.cookie_path)
        .secure(settings.cookie_secure);
    if let Some(cookie_domain) = &settings.cookie_domain {
        auth_cookie = auth_cookie.domain(cookie_domain);
    }
    if let Some(expires) = maybe_expires {
        let maxage = (expires - Utc::now()).num_seconds();
        if maxage > 0 {
            auth_cookie = auth_cookie.max_age(time::Duration::seconds(maxage));
        }
    }
    response.header(header::SET_COOKIE, auth_cookie.finish().to_string())
}
fn add_auth_cookie ( settings : Arc < Settings > , auth_token : String , maybe_expires : Option < DateTime < Utc > > , response : response :: Builder , ) -> response :: Builder { let mut auth_cookie = cookie :: Cookie :: build ( & settings . auth_cookie , auth_token ) . http_only ( true ) . path ( & settings . cookie_path ) . secure ( settings . cookie_secure ) ; if let Some ( cookie_domain ) = & settings . cookie_domain { auth_cookie = auth_cookie . domain ( cookie_domain ) ; } if let Some ( expires ) = maybe_expires { let maxage = ( expires - Utc :: now ( ) ) . num_seconds ( ) ; if maxage > 0 { auth_cookie = auth_cookie . max_age ( time :: Duration :: seconds ( maxage ) ) ; } } response . header ( header :: SET_COOKIE , auth_cookie . finish ( ) . to_string ( ) ) }
Add a new auth cookie to the response
Add a new auth cookie to the response
settings
Arc<Settings>
auth_token
String
maybe_expires
Option<DateTime<Utc>>
response
response::Builder
settings
Arc<Settings>
auth_token
String
maybe_expires
Option<DateTime<Utc>>
response
response::Builder