pub struct User {Show 17 fields
pub uuid: Uuid,
pub role: Option<Role>,
pub external_id: Option<CompactString>,
pub avatar: Option<String>,
pub username: CompactString,
pub email: CompactString,
pub name_first: CompactString,
pub name_last: CompactString,
pub admin: bool,
pub totp_enabled: bool,
pub totp_last_used: Option<NaiveDateTime>,
pub totp_secret: Option<String>,
pub language: CompactString,
pub toast_position: UserToastPosition,
pub start_on_grouped_servers: bool,
pub has_password: bool,
pub created: NaiveDateTime,
}Fields§
§uuid: Uuid§role: Option<Role>§external_id: Option<CompactString>§avatar: Option<String>§username: CompactString§email: CompactString§name_first: CompactString§name_last: CompactString§admin: bool§totp_enabled: bool§totp_last_used: Option<NaiveDateTime>§totp_secret: Option<String>§language: CompactString§toast_position: UserToastPosition§start_on_grouped_servers: bool§has_password: bool§created: NaiveDateTimeImplementations§
Source§impl User
impl User
pub async fn create_automatic_admin( database: &Database, username: &str, email: &str, name_first: &str, name_last: &str, password: &str, ) -> Result<Uuid, DatabaseError>
pub async fn by_external_id( database: &Database, external_id: &str, ) -> Result<Option<Self>, DatabaseError>
Sourcepub async fn by_session_cached(
database: &Database,
session: &str,
) -> Result<Option<(Self, UserSession)>, Error>
pub async fn by_session_cached( database: &Database, session: &str, ) -> Result<Option<(Self, UserSession)>, Error>
Returns the user and session associated with the given session string, if valid.
Cached for 5 seconds.
Sourcepub async fn by_api_key_cached(
database: &Database,
key: &str,
) -> Result<Option<(Self, UserApiKey)>, Error>
pub async fn by_api_key_cached( database: &Database, key: &str, ) -> Result<Option<(Self, UserApiKey)>, Error>
Returns the user and API key associated with the given API key string, if valid.
Cached for 5 seconds.
pub async fn by_credential_id( database: &Database, credential_id: &CredentialID, ) -> Result<Option<(Self, UserSecurityKey)>, DatabaseError>
pub async fn by_email( database: &Database, email: &str, ) -> Result<Option<Self>, DatabaseError>
pub async fn by_email_password( database: &Database, email: &str, password: &str, ) -> Result<Option<Self>, DatabaseError>
pub async fn by_username( database: &Database, username: &str, ) -> Result<Option<Self>, DatabaseError>
pub async fn by_username_password( database: &Database, username: &str, password: &str, ) -> Result<Option<Self>, DatabaseError>
pub async fn by_username_public_key( database: &Database, username: &str, public_key: PublicKey, ) -> Result<Option<Self>, DatabaseError>
pub async fn by_role_uuid_with_pagination( database: &Database, role_uuid: Uuid, page: i64, per_page: i64, search: Option<&str>, ) -> Result<Pagination<Self>, DatabaseError>
pub async fn all_with_pagination( database: &Database, page: i64, per_page: i64, search: Option<&str>, ) -> Result<Pagination<Self>, DatabaseError>
pub async fn count(database: &Database) -> i64
pub async fn validate_password( &self, database: &Database, password: &str, ) -> Result<bool, DatabaseError>
Sourcepub async fn update_password(
&mut self,
database: &Database,
password: Option<&str>,
) -> Result<(), DatabaseError>
pub async fn update_password( &mut self, database: &Database, password: Option<&str>, ) -> Result<(), DatabaseError>
Update the User password, None will disallow password login and not require one when changing
pub fn require_two_factor(&self, settings: &AppSettings) -> bool
pub fn into_api_object( self, storage_url_retriever: &StorageUrlRetriever<'_>, ) -> ApiUser
pub fn into_api_full_object( self, storage_url_retriever: &StorageUrlRetriever<'_>, ) -> ApiFullUser
Trait Implementations§
Source§impl ByUuid for User
impl ByUuid for User
fn by_uuid<'life0, 'async_trait>(
database: &'life0 Database,
uuid: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Self, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn by_uuid_cached<'life0, 'async_trait>(
database: &'life0 Database,
uuid: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn by_uuid_optional<'life0, 'async_trait>(
database: &'life0 Database,
uuid: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, DatabaseError>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn by_uuid_optional_cached<'life0, 'async_trait>(
database: &'life0 Database,
uuid: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn get_fetchable(uuid: Uuid) -> Fetchable<Self>
fn get_fetchable_from_row( row: &PgRow, column: impl AsRef<str>, ) -> Option<Fetchable<Self>>
Source§impl CreatableModel for User
impl CreatableModel for User
type CreateOptions<'a> = CreateUserOptions
type CreateResult = User
fn get_create_handlers() -> &'static LazyLock<CreateListenerList<Self>>
fn create<'life0, 'life1, 'async_trait>(
state: &'life0 State,
options: Self::CreateOptions<'life1>,
) -> Pin<Box<dyn Future<Output = Result<Self, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register_create_handler<'async_trait, F>(
priority: ListenerPriority,
callback: F,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
F: 'async_trait + for<'a> Fn(&'a mut Self::CreateOptions<'_>, &'a mut InsertQueryBuilder<'_>, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'a>> + Send + Sync + 'static,
Self: 'async_trait,
Source§fn blocking_register_create_handler<F: for<'a> Fn(&'a mut Self::CreateOptions<'_>, &'a mut InsertQueryBuilder<'_>, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'a>> + Send + Sync + 'static>(
priority: ListenerPriority,
callback: F,
)
fn blocking_register_create_handler<F: for<'a> Fn(&'a mut Self::CreateOptions<'_>, &'a mut InsertQueryBuilder<'_>, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'a>> + Send + Sync + 'static>( priority: ListenerPriority, callback: F, )
Warning Read more
fn run_create_handlers<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
options: &'life0 mut Self::CreateOptions<'life1>,
query_builder: &'life2 mut InsertQueryBuilder<'_>,
state: &'life3 State,
transaction: &'life4 mut Transaction<'life5, Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
Source§impl DeletableModel for User
impl DeletableModel for User
type DeleteOptions = ()
fn get_delete_handlers() -> &'static LazyLock<DeleteListenerList<Self>>
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
state: &'life1 State,
options: Self::DeleteOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register_delete_handler<'async_trait, F>( priority: ListenerPriority, callback: F, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
Source§fn blocking_register_delete_handler<F: for<'a> Fn(&'a Self, &'a Self::DeleteOptions, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> + Send + Sync + 'static>(
priority: ListenerPriority,
callback: F,
)
fn blocking_register_delete_handler<F: for<'a> Fn(&'a Self, &'a Self::DeleteOptions, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> + Send + Sync + 'static>( priority: ListenerPriority, callback: F, )
Warning Read more
fn run_delete_handlers<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
options: &'life1 Self::DeleteOptions,
state: &'life2 State,
transaction: &'life3 mut Transaction<'life4, Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Source§impl<'de> Deserialize<'de> for User
impl<'de> Deserialize<'de> for User
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl UpdatableModel for User
impl UpdatableModel for User
type UpdateOptions = UpdateUserOptions
fn get_update_handlers() -> &'static LazyLock<UpdateListenerList<Self>>
fn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
state: &'life1 State,
options: Self::UpdateOptions,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register_update_handler<'async_trait, F>(
priority: ListenerPriority,
callback: F,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
F: 'async_trait + for<'a> Fn(&'a mut Self, &'a mut Self::UpdateOptions, &'a mut UpdateQueryBuilder<'_>, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'a>> + Send + Sync + 'static,
Self: 'async_trait,
Source§fn blocking_register_update_handler<F: for<'a> Fn(&'a mut Self, &'a mut Self::UpdateOptions, &'a mut UpdateQueryBuilder<'_>, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'a>> + Send + Sync + 'static>(
priority: ListenerPriority,
callback: F,
)
fn blocking_register_update_handler<F: for<'a> Fn(&'a mut Self, &'a mut Self::UpdateOptions, &'a mut UpdateQueryBuilder<'_>, &'a State, &'a mut Transaction<'_, Postgres>) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'a>> + Send + Sync + 'static>( priority: ListenerPriority, callback: F, )
Warning Read more
fn run_update_handlers<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 mut self,
options: &'life1 mut Self::UpdateOptions,
query_builder: &'life2 mut UpdateQueryBuilder<'_>,
state: &'life3 State,
transaction: &'life4 mut Transaction<'life5, Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more