fix: add more debug logs
This commit is contained in:
parent
fdb868d10c
commit
18b33c00a7
2 changed files with 6 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use axum::{extract::State, http::StatusCode, response::{Html, IntoResponse}, Extension, Form, Json};
|
||||
use chrono::{Duration, Utc};
|
||||
use fully_pub::fully_pub;
|
||||
use log::error;
|
||||
use log::{debug, error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use kernel::{models::authorization::Authorization, repositories::users::get_user_by_id};
|
||||
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
|
||||
const AUTHORIZATION_CODE_TTL_SECONDS: i64 = 120;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[fully_pub]
|
||||
struct AccessTokenRequestParams {
|
||||
grant_type: String,
|
||||
|
|
@ -48,6 +48,7 @@ pub async fn get_access_token(
|
|||
let authorization = match authorizations_res {
|
||||
Ok(val) => val,
|
||||
Err(sqlx::Error::RowNotFound) => {
|
||||
error!("Received invalid authorization_code.");
|
||||
return (
|
||||
StatusCode::BAD_REQUEST,
|
||||
Json("Invalid authorization_code.")
|
||||
|
|
@ -68,12 +69,15 @@ pub async fn get_access_token(
|
|||
Utc::now().signed_duration_since(ts) < Duration::seconds(AUTHORIZATION_CODE_TTL_SECONDS)
|
||||
});
|
||||
if !is_code_valid {
|
||||
debug!("Received expired authorization code");
|
||||
return (
|
||||
StatusCode::BAD_REQUEST,
|
||||
Json("Authorization code has expired.")
|
||||
).into_response();
|
||||
}
|
||||
|
||||
debug!("Generating access_token and id_token.");
|
||||
|
||||
// 2.3. Fetch user resource owner
|
||||
let user = get_user_by_id(&app_state.db, &authorization.user_id)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use jsonwebkey_convert_repaired::RSAPublicKey;
|
||||
use jsonwebkey_convert_repaired::der::FromPem;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue