Skip to main content

pubhubs/servers/phc/
user_card.rs

1//! User endpoints related to the issuance of the pubhubs yivi card
2use crate::api;
3
4use std::rc::Rc;
5
6use super::server::*;
7use crate::api::phc::user::*;
8
9impl App {
10    /// Implements [`api::phc::user::CardPseudEP`] endpoint.
11    pub async fn handle_user_card_pseud(
12        app: Rc<Self>,
13        auth_token: actix_web::web::Header<AuthToken>,
14    ) -> api::Result<CardPseudResp> {
15        let Ok((user_state, _)) = app
16            .open_auth_token_and_get_user_state(auth_token.into_inner())
17            .await?
18        else {
19            return Ok(CardPseudResp::RetryWithNewAuthToken);
20        };
21
22        log::debug!("user {} retrieved registration pseudonym", user_state.id);
23
24        Ok(CardPseudResp::Success(api::Signed::new(
25            &*app.jwt_key,
26            &CardPseudPackage {
27                card_pseud: user_state.card_id(),
28                registration_date: user_state.registration_date,
29            },
30            app.card_pseud_validity,
31        )?))
32    }
33}