feat: store user agent with sessions
This commit is contained in:
parent
5112a6ce35
commit
2c44f788d9
9 changed files with 23 additions and 5 deletions
|
|
@ -0,0 +1,2 @@
|
|||
alter table sessions
|
||||
drop column user_agent;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
alter table sessions
|
||||
add column user_agent text;
|
||||
|
|
@ -10,6 +10,7 @@ pub struct Session {
|
|||
pub id: i64,
|
||||
pub user_id: i64,
|
||||
pub last_seen: i64,
|
||||
pub user_agent: Option<String>,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ impl gpodder::AuthStore for SqliteRepository {
|
|||
id: session.id,
|
||||
last_seen: DateTime::from_timestamp(session.last_seen, 0).unwrap(),
|
||||
user: user.into(),
|
||||
user_agent: session.user_agent.clone(),
|
||||
})),
|
||||
Ok(None) => Ok(None),
|
||||
Err(err) => Err(DbError::from(err).into()),
|
||||
|
|
@ -79,6 +80,7 @@ impl gpodder::AuthStore for SqliteRepository {
|
|||
id: session.id,
|
||||
user_id: session.user.id,
|
||||
last_seen: session.last_seen.timestamp(),
|
||||
user_agent: session.user_agent.clone(),
|
||||
}
|
||||
.insert_into(sessions::table)
|
||||
.execute(&mut self.pool.get().map_err(DbError::from)?)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ diesel::table! {
|
|||
id -> BigInt,
|
||||
user_id -> BigInt,
|
||||
last_seen -> BigInt,
|
||||
user_agent -> Nullable<Text>,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue