Skip to content

Commit

Permalink
Custom quote total & Discount
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn committed Feb 13, 2024
1 parent a9fceb1 commit e9f0f2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
target/

config.json

tmp/
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
23 changes: 11 additions & 12 deletions server/wilford/src/routes/auth.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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;
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 {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion server/wilford/src/routes/v1/auth/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit e9f0f2a

Please sign in to comment.