feat: store user agent with sessions

This commit is contained in:
Jef Roosens 2025-03-29 15:37:50 +01:00
parent 5112a6ce35
commit 2c44f788d9
No known key found for this signature in database
GPG key ID: 21FD3D77D56BAF49
9 changed files with 23 additions and 5 deletions

View file

@ -56,6 +56,7 @@ pub struct EpisodeAction {
pub struct Session {
pub id: i64,
pub last_seen: DateTime<Utc>,
pub user_agent: Option<String>,
pub user: User,
}

View file

@ -71,11 +71,16 @@ impl GpodderRepository {
}
}
pub fn create_session(&self, user: &models::User) -> Result<models::Session, AuthErr> {
pub fn create_session(
&self,
user: &models::User,
user_agent: Option<String>,
) -> Result<models::Session, AuthErr> {
let session = models::Session {
id: rand::thread_rng().gen(),
last_seen: Utc::now(),
user: user.clone(),
user_agent,
};
self.store.insert_session(&session)?;