Skip to content

Commit 681b025

Browse files
committed
models: Created persistent session model.
1 parent fb78828 commit 681b025

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ cookie = { version = "=0.16.0", features = ["secure"] }
5050
dashmap = { version = "=5.2.0", features = ["raw-api"] }
5151
derive_deref = "=1.1.1"
5252
dialoguer = "=0.10.0"
53-
diesel = { version = "=1.4.8", features = ["postgres", "serde_json", "chrono", "r2d2"] }
53+
diesel = { version = "=1.4.8", features = ["postgres", "serde_json", "chrono", "r2d2", "network-address"] }
5454
diesel_full_text_search = "=1.0.1"
5555
diesel_migrations = { version = "=1.4.0", features = ["postgres"] }
5656
dotenv = "=0.15.0"
@@ -61,6 +61,7 @@ hex = "=0.4.3"
6161
http = "=0.2.6"
6262
hyper = { version = "=0.14.18", features = ["client", "http1"] }
6363
indexmap = { version = "=1.8.0", features = ["serde-1"] }
64+
ipnetwork = "0.18.0"
6465
tikv-jemallocator = { version = "=0.4.3", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
6566
lettre = { version = "=0.10.0-rc.4", default-features = false, features = ["file-transport", "smtp-transport", "native-tls", "hostname", "builder"] }
6667
minijinja = "=0.15.0"

src/models.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub use self::action::{insert_version_owner_action, VersionAction, VersionOwnerAction};
22
pub use self::badge::{Badge, CrateBadge, MaintenanceStatus};
33
pub use self::category::{Category, CrateCategory, NewCategory};
4+
pub use self::persistent_session::PersistentSession;
45
pub use self::crate_owner_invitation::{CrateOwnerInvitation, NewCrateOwnerInvitationOutcome};
56
pub use self::dependency::{Dependency, DependencyKind, ReverseDependency};
67
pub use self::download::VersionDownload;
@@ -20,6 +21,7 @@ pub mod helpers;
2021
mod action;
2122
mod badge;
2223
pub mod category;
24+
mod persistent_session;
2325
mod crate_owner_invitation;
2426
pub mod dependency;
2527
mod download;

src/models/persistent_session.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use crate::schema::persistent_sessions;
2+
use chrono::NaiveDateTime;
3+
use ipnetwork::IpNetwork;
4+
5+
#[derive(Clone, Debug, PartialEq, Eq, Identifiable, Queryable)]
6+
#[table_name = "persistent_sessions"]
7+
pub struct PersistentSession {
8+
pub id: i32,
9+
pub user_id: i32,
10+
pub hashed_token: Vec<u8>,
11+
pub created_at: NaiveDateTime,
12+
pub last_used_at: NaiveDateTime,
13+
pub revoked: bool,
14+
pub last_ip_address: IpNetwork,
15+
pub last_user_agent: String,
16+
}

0 commit comments

Comments
 (0)