domain: add cross-cutting value objects (SystemId, DateTimeStamp, Checksum, StructuredData)
This commit is contained in:
@@ -4,13 +4,13 @@ use axum::{
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use domain::value_objects::{Role, UserId};
|
||||
use domain::value_objects::SystemId;
|
||||
use serde_json::json;
|
||||
use crate::state::AppState;
|
||||
|
||||
pub struct JwtClaims {
|
||||
pub user_id: UserId,
|
||||
pub role: Role,
|
||||
pub user_id: SystemId,
|
||||
pub role: String,
|
||||
}
|
||||
|
||||
impl FromRequestParts<AppState> for JwtClaims {
|
||||
|
||||
@@ -19,7 +19,7 @@ pub async fn register(
|
||||
ValidatedJson(req): ValidatedJson<RegisterRequest>,
|
||||
) -> Result<(StatusCode, Json<AuthResponse>), AppError> {
|
||||
let user = state.register_uc.execute(&req.email, &req.password).await?;
|
||||
let token = state.token_issuer.issue(&user.id, &user.role).await.map_err(AppError::from)?;
|
||||
let token = state.token_issuer.issue(&user.id, "user").await.map_err(AppError::from)?;
|
||||
Ok((StatusCode::CREATED, Json(AuthResponse { token, user: UserResponse::from_domain(&user) })))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user