Skip to content

Commit 920e730

Browse files
fix: added logging for testing
1 parent 74b7bd1 commit 920e730

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

control-plane/api-gateway/src/auth_service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use chrono::{DateTime, Utc};
22
use entity::{invalid_jwt, key, user, InvalidJwt, Key, User};
3+
use tracing::warn;
34
use sea_orm::{
45
ActiveModelTrait, ActiveValue, ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter, Set,
56
};
@@ -116,8 +117,8 @@ impl AuthService {
116117
// Decrypt the password
117118
let password = decrypt_password(&encrypted_password, &rsa_key.private_key)?;
118119

119-
// Verify password
120120
if !verify_password(&password, &user.salt, &user.password)? {
121+
warn!(username = %username, "failed login attempt");
121122
return Err(AuthError::InvalidCredentials);
122123
}
123124

control-plane/api-gateway/src/rbac_service.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use entity::{
55
use sea_orm::{
66
ActiveModelTrait, ActiveValue, ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter,
77
};
8+
use tracing::info;
89
use uuid::Uuid;
910

1011
#[derive(Debug, Clone)]
@@ -122,13 +123,12 @@ impl RbacService {
122123
.await?;
123124

124125
if let Some(existing) = existing {
125-
// Update existing role
126126
let mut active: user_organization::ActiveModel = existing.clone().into();
127127
active.role_id = ActiveValue::Set(role_id);
128128
let updated = active.update(&self.db).await?;
129+
info!(user_id = %user_id, organization_id = %organization_id, role_id = %role_id, "role updated");
129130
Ok(updated)
130131
} else {
131-
// Create new user-organization relationship
132132
let new_user_org = user_organization::ActiveModel {
133133
id: ActiveValue::Set(Uuid::new_v4()),
134134
user_id: ActiveValue::Set(user_id),
@@ -138,6 +138,7 @@ impl RbacService {
138138
};
139139

140140
let result = new_user_org.insert(&self.db).await?;
141+
info!(user_id = %user_id, organization_id = %organization_id, role_id = %role_id, "role assigned");
141142
Ok(result)
142143
}
143144
}

0 commit comments

Comments
 (0)