mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-02 13:39:21 +00:00
99aac07714
* Mark database fields as sensitive so they dont show up in logs * add file * fix test * Update crates/apub/src/objects/person.rs Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> * Update crates/apub/src/objects/community.rs Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> * Update crates/apub/src/objects/instance.rs Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
39 lines
1.4 KiB
Rust
39 lines
1.4 KiB
Rust
#[cfg(feature = "full")]
|
|
use crate::schema::login_token;
|
|
use crate::{newtypes::LocalUserId, sensitive::SensitiveString};
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_with::skip_serializing_none;
|
|
#[cfg(feature = "full")]
|
|
use ts_rs::TS;
|
|
|
|
/// Stores data related to a specific user login session.
|
|
#[skip_serializing_none]
|
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = login_token))]
|
|
#[cfg_attr(feature = "full", diesel(primary_key(token)))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
pub struct LoginToken {
|
|
/// Jwt token for this login
|
|
#[serde(skip)]
|
|
pub token: SensitiveString,
|
|
pub user_id: LocalUserId,
|
|
/// Time of login
|
|
pub published: DateTime<Utc>,
|
|
/// IP address where login was made from, allows invalidating logins by IP address.
|
|
/// Could be stored in truncated format, or store derived information for better privacy.
|
|
pub ip: Option<String>,
|
|
pub user_agent: Option<String>,
|
|
}
|
|
|
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
#[cfg_attr(feature = "full", diesel(table_name = login_token))]
|
|
pub struct LoginTokenCreateForm {
|
|
pub token: SensitiveString,
|
|
pub user_id: LocalUserId,
|
|
pub ip: Option<String>,
|
|
pub user_agent: Option<String>,
|
|
}
|