diff --git a/.gitignore b/.gitignore index cfa5895..1c8d956 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ target/ config.json + +tmp/ diff --git a/docker-compose.yml b/docker-compose.yml index 4f60440..0fd0701 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,9 +56,6 @@ services: - "ESPOCRM_ADMIN_PASSWORD=admin" - "ESPOCRM_SITE_URL=http://localhost:2524" volumes: - - "espo-data:/var/www/html" + - "./tmp/espocrm:/var/www/html" depends_on: - mariadb-espocrm - -volumes: - espo-data: {} diff --git a/server/wilford/src/routes/auth.rs b/server/wilford/src/routes/auth.rs index ed393a4..8a393fd 100644 --- a/server/wilford/src/routes/auth.rs +++ b/server/wilford/src/routes/auth.rs @@ -1,6 +1,7 @@ use crate::espo::user::EspoUser; use crate::routes::appdata::{WDatabase, WEspo}; use crate::routes::error::{WebError, WebResult}; +use actix_web::cookie::time::OffsetDateTime; use actix_web::dev::Payload; use actix_web::{FromRequest, HttpRequest}; use database::constant_access_tokens::ConstantAccessToken; @@ -8,7 +9,6 @@ use database::oauth2_client::AccessToken; use std::collections::HashSet; use std::future::Future; use std::pin::Pin; -use actix_web::cookie::time::OffsetDateTime; #[derive(Debug, Clone)] pub struct Auth { @@ -36,17 +36,16 @@ impl FromRequest for Auth { Box::pin(async move { let token = get_authorization_token(&req)?; - let token_info = - match AccessToken::get_by_token(&database, &token).await? { - Some(v) => { - if v.expires_at < OffsetDateTime::now_utc().unix_timestamp() { - return Err(WebError::Unauthorized); - } else { - v - } - }, - None => return Err(WebError::Unauthorized), - }; + let token_info = match AccessToken::get_by_token(&database, &token).await? { + Some(v) => { + if v.expires_at < OffsetDateTime::now_utc().unix_timestamp() { + return Err(WebError::Unauthorized); + } else { + v + } + } + None => return Err(WebError::Unauthorized), + }; let espo_user = EspoUser::get_by_id(&espo_client, &token_info.espo_user_id) .await diff --git a/server/wilford/src/routes/v1/auth/authorize.rs b/server/wilford/src/routes/v1/auth/authorize.rs index e847bae..9c4b5b9 100644 --- a/server/wilford/src/routes/v1/auth/authorize.rs +++ b/server/wilford/src/routes/v1/auth/authorize.rs @@ -93,7 +93,8 @@ pub async fn authorize( serde_qs::to_string(&RedirectFragment { access_token: access_token.token, token_type: "bearer", - expires_in: access_token.expires_at - OffsetDateTime::now_utc().unix_timestamp(), + expires_in: access_token.expires_at + - OffsetDateTime::now_utc().unix_timestamp(), state, }) .expect("Serializing query string"),