pub async fn me(mut req: tide::Request<Database>) -> tide::Result {
    if let Some(person) = request_person(&mut req).await? {
        let jwt = issue_jwt(&person.exterior.uid, &UI_AUDIENCE, SESSION_HOURS as u64)?;

        person.log(req.state(), LogEvent::Session).await?;

        let mut p_json = person_json(&person, &jwt);
        p_json["num_partners"] = person.count_partners(req.state()).await?.into();
        p_json["reports_pending"] = Involvement::count_for_participant(
            req.state(),
            &person.exterior.uid,
            Some(involvement::Mode::Interest),
            Some(involvement::Mode::Saved),
        )
        .await?
        .into();

        okay_with_cookie(
            &p_json,
            Cookie::build(TOKEN_COOKIE, jwt)
                .path("/")
                .max_age(Duration::hours(SESSION_HOURS))
                //.domain(&*COOKIE_DOMAIN)
                .secure(cfg!(not(debug_assertions))) // Allow HTTP when in debug mode, require HTTPS in release mode
                .http_only(true)
                .same_site(tide::http::cookies::SameSite::Lax)
                .finish(),
        )
    } else {
        okay(&json!({"authenticated": false}))
    }
}
/// Retrieve UI-approriate information about the current user in JSON
/// format. Includes the token, uid, username, and so on.
Retrieve UI-approriate information about the current user in JSON
format. Includes the token, uid, username, and so on.
Retrieve UI - approriate information about the current user in JSON format . Includes the token uid username and so on .
pub async fn me(mut req: tide::Request<Database>) -> tide::Result {
    if let Some(person) = request_person(&mut req).await? {
        let jwt = issue_jwt(&person.exterior.uid, &UI_AUDIENCE, SESSION_HOURS as u64)?;
        person.log(req.state(), LogEvent::Session).await?;
        let mut p_json = person_json(&person, &jwt);
        p_json["num_partners"] = person.count_partners(req.state()).await?.into();
        p_json["reports_pending"] = Involvement::count_for_participant(
            req.state(),
            &person.exterior.uid,
            Some(involvement::Mode::Interest),
            Some(involvement::Mode::Saved),
        )
        .await?
        .into();
        okay_with_cookie(
            &p_json,
            Cookie::build(TOKEN_COOKIE, jwt)
                .path("/")
                .max_age(Duration::hours(SESSION_HOURS))
                //.domain(&*COOKIE_DOMAIN)
                .secure(cfg!(not(debug_assertions))) // Allow HTTP when in debug mode, require HTTPS in release mode
                .http_only(true)
                .same_site(tide::http::cookies::SameSite::Lax)
                .finish(),
        )
    } else {
        okay(&json!({"authenticated": false}))
    }
}
pub async fn me ( mut req : tide :: Request < Database > ) -> tide :: Result { if let Some ( person ) = request_person ( & mut req ) . await ? { let jwt = issue_jwt ( & person . exterior . uid , & UI_AUDIENCE , SESSION_HOURS as u64 ) ? ; person . log ( req . state ( ) , LogEvent :: Session ) . await ? ; let mut p_json = person_json ( & person , & jwt ) ; p_json [ " " ] = person . count_partners ( req . state ( ) ) . await ? . into ( ) ; p_json [ " " ] = Involvement :: count_for_participant ( req . state ( ) , & person . exterior . uid , Some ( involvement :: Mode :: Interest ) , Some ( involvement :: Mode :: Saved ) , ) . await ? . into ( ) ; okay_with_cookie ( & p_json , Cookie :: build ( TOKEN_COOKIE , jwt ) . path ( " " ) . max_age ( Duration :: hours ( SESSION_HOURS ) ) //.domain(&*COOKIE_DOMAIN) . secure ( cfg ! ( not ( debug_assertions ) ) ) // Allow HTTP when in debug mode, require HTTPS in release mode . http_only ( true ) . same_site ( tide :: http :: cookies :: SameSite :: Lax ) . finish ( ) , ) } else { okay ( & json ! ( { " " false } ) ) } }
Retrieve UI-approriate information about the current user in JSON
format.
Retrieve UI - approriate information about the current user in JSON format .
req
tide::Request<Database>
req
tide::Request<Database>