feat: store user agent with sessions
This commit is contained in:
parent
5112a6ce35
commit
2c44f788d9
9 changed files with 23 additions and 5 deletions
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue