Skip to content

Commit

Permalink
fix token response for /token endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill-K-1 committed Jul 30, 2024
1 parent 0fd9511 commit 730888f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gov-portal-db/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ pub enum TokenQuery {
NoMessage {},
}

#[derive(Debug, Serialize)]
pub struct TokenResponse {
pub token: SessionToken,
}

/// JSON-serialized request passed as POST-data to `/users` endpoint
#[derive(Debug, Deserialize)]
pub struct UsersRequest {
Expand Down Expand Up @@ -173,14 +178,15 @@ pub async fn start(
async fn token_route(
State(state): State<AppState>,
Json(req): Json<TokenQuery>,
) -> Result<Json<SessionToken>, String> {
) -> Result<Json<TokenResponse>, String> {
tracing::debug!("[/token] Request {req:?}");

let res = match req {
TokenQuery::Message { data } => state
.session_manager
.acquire_token_with_wallet_signed_message(&data)
.map_err(|e| e.to_string()),
.map_err(|e| e.to_string())
.map(|token| TokenResponse { token }),
TokenQuery::NoMessage {} => Err("Resource Not Found".to_owned()),
};

Expand Down

0 comments on commit 730888f

Please sign in to comment.