Skip to content

Commit

Permalink
chore: add error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Apr 4, 2023
1 parent db22fc7 commit 7fe65d2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/deployment/cloud-dev.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ SIGN_KEY = "{{ key "service/development/affine-cloud/sign_key" }}"
MAIL_ACCOUNT = "{{ key "service/development/affine-cloud/mail_account" }}"
MAIL_PASSWORD = "{{ key "service/development/affine-cloud/mail_password" }}"
JWST_DEV = "1"
AFFINE_CLOUD_LOG = "debug,mio=off,hyper=off,rustls=off,tantivy=off,sqlx::query=off,jwst_rpc=trace,jwst_rpc::context=info,affine_cloud=trace"
EOH

destination = "secrets/.env"
env = true
}

config {
image = "ghcr.io/toeverything/cloud:${DOCKER_TAG}"
image = "ghcr.io/toeverything/cloud-self-hosted:${DOCKER_TAG}"
force_pull = true
ports = ["affine-cloud"]
}
Expand Down
17 changes: 10 additions & 7 deletions .github/deployment/cloud-stage.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ job "affine-cloud-stage" {
}

service {
tags = ["urlprefix-stage.affine.live/", "urlprefix-stage.affine.pro/"]
tags = ["urlprefix-api-stage.affine.live/"]
port = "affine-cloud"
check {
name = "Affine Cloud Stage Check"
Expand All @@ -61,19 +61,22 @@ job "affine-cloud-stage" {
}
template {
data = <<EOH
DOCKER_TAG = "{{ key "service/stage/affine-cloud/tag" }}"
DATABASE_URL = "postgresql://affine:{{ key "service/stage/affine-cloud/database_password" }}@{{ env "NOMAD_ADDR_postgres" }}/affine"
SIGN_KEY = "{{ key "service/stage/affine-cloud/sign_key" }}"
MAIL_ACCOUNT = "{{ key "service/stage/affine-cloud/mail_account" }}"
MAIL_PASSWORD = "{{ key "service/stage/affine-cloud/mail_password" }}"
DOCKER_TAG = "{{ key "service/stage/affine-cloud/tag" }}"
DATABASE_URL = "postgresql://affine:{{ key "service/stage/affine-cloud/database_password" }}@{{ env "NOMAD_ADDR_postgres" }}/affine"
SIGN_KEY = "{{ key "service/stage/affine-cloud/sign_key" }}"
MAIL_ACCOUNT = "{{ key "service/stage/affine-cloud/mail_account" }}"
MAIL_PASSWORD = "{{ key "service/stage/affine-cloud/mail_password" }}"
AFFINE_CLOUD_LOG = "info,mio=off,hyper=off,rustls=off,tantivy=off,sqlx::query=off,jwst_rpc=trace,jwst_rpc::context=info,affine_cloud=trace"
JWT_ACCESS_TOKEN_EXPIRES_IN = "3600"
JWT_REFRESH_TOKEN_EXPIRES_IN = "2592000"
EOH

destination = "secrets/.env"
env = true
}

config {
image = "ghcr.io/toeverything/cloud:${DOCKER_TAG}"
image = "ghcr.io/toeverything/cloud-self-hosted:${DOCKER_TAG}"
force_pull = true
ports = ["affine-cloud"]
}
Expand Down
15 changes: 10 additions & 5 deletions apps/cloud/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,24 @@ pub async fn make_token(
}
}
MakeToken::Google { token } => {
if let Ok(claims) = ctx
match ctx
.firebase
.lock()
.await
.decode_google_token(token, ctx.config.refresh_token_expires_in)
.await
{
match ctx.db.firebase_user_login(&claims).await {
Ok(claims) => match ctx.db.firebase_user_login(&claims).await {
Ok(user) => (Ok(Some(user)), None),
Err(_) => return ErrorStatus::InternalServerError.into_response(),
Err(e) => {
error!("failed to auth: {:?}", e,);
return ErrorStatus::InternalServerError.into_response();
}
},
Err(e) => {
error!("failed to check token: {:?}", e);
return ErrorStatus::Unauthorized.into_response();
}
} else {
(Ok(None), None)
}
}
MakeToken::Refresh { token } => {
Expand Down

1 comment on commit 7fe65d2

@vercel
Copy link

@vercel vercel bot commented on 7fe65d2 Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.