- Remove all use slog::* imports and slog::Logger fields/parameters - Replace slog::info!/warn!/error! with tracing::info!/warn!/error! - AppService: remove pub logs: slog::Logger field, update callers of AppEmail::init(), MessageProducer::new(), RoomService::new(), start_email_worker(), start_room_workers() - auth/: captcha, email, login, logout, password, register, rsa, totp - git/: archive, blame, blob, branch, commit, contributors, diff, refs, star, tag, tree, watch - agent/: billing (ai_usage_recorded), code_review, pr_summary, sync - project/activity.rs, workspace/alert.rs
29 lines
947 B
Rust
29 lines
947 B
Rust
use crate::AppService;
|
|
use crate::error::AppError;
|
|
use models::users::user_activity_log;
|
|
use sea_orm::*;
|
|
use serde_json::json;
|
|
use session::Session;
|
|
|
|
impl AppService {
|
|
pub async fn auth_logout(&self, context: &Session) -> Result<(), AppError> {
|
|
if let Some(user_uid) = context.user() {
|
|
tracing::info!(user_uid = %user_uid, ip = ?context.ip_address(), "User logged out");
|
|
let _ = user_activity_log::ActiveModel {
|
|
user_uid: Set(Option::from(user_uid)),
|
|
action: Set("logout".to_string()),
|
|
ip_address: Set(context.ip_address()),
|
|
user_agent: Set(context.user_agent()),
|
|
details: Set(json!({})),
|
|
created_at: Set(chrono::Utc::now()),
|
|
..Default::default()
|
|
}
|
|
.insert(&self.db)
|
|
.await;
|
|
}
|
|
context.clear_user();
|
|
context.clear();
|
|
Ok(())
|
|
}
|
|
}
|