diff --git a/src/main.rs b/src/main.rs index 5ed9322..10980e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -187,6 +187,7 @@ async fn run_server(db: Arc) { // Authentication .route_layer(middleware::from_fn_with_state(shared_state.clone(), routes::auth::auth_middleware)) .routes(routes!(routes::auth::auth)) + .routes(routes!(routes::auth::check_token)) .route("/", get(index)) .with_state(shared_state) diff --git a/src/routes/auth.rs b/src/routes/auth.rs index 3c4d226..3fcb41a 100644 --- a/src/routes/auth.rs +++ b/src/routes/auth.rs @@ -57,6 +57,30 @@ pub async fn auth(State(state): State>, Json(payload): Json) -> Json { + let token_data = decode::(&payload.token, &KEYS.decoding, &Validation::default()); + match token_data { + Ok(_claims) => Json(true), + Err(_) => Json(false) + } +} + impl AuthBody { fn new(access_token: String) -> Self { Self {