pub struct User {
pub id: i64,
pub identity_hash: [u8; 32],
pub auth_verifier: String,
}Expand description
Represents a registered user in the system.
Users are identified by an identity_hash (a hash of their public identity)
and authenticated via an auth_verifier. Neither field stores a raw password.
This keeps the server from ever knowing who the user actually is.
Fields§
§id: i64§identity_hash: [u8; 32]§auth_verifier: StringImplementations§
Source§impl User
impl User
Sourcepub async fn create(
pool: &SqlitePool,
identity_hash: &Vec<u8>,
auth_verifier: String,
) -> Result<()>
pub async fn create( pool: &SqlitePool, identity_hash: &Vec<u8>, auth_verifier: String, ) -> Result<()>
Inserts a new user into the users table via the provided SqlitePool.
Both identity_hash and auth_verifier are expected to be pre-processed
on the client side before being sent to this function.
§Errors
- Returns [
sqlx::Error::Database] on a uniqueness violation, meaning a user with the sameidentity_hashalready exists. - Returns [
sqlx::Error] if the database query fails for any other reason.
Sourcepub async fn verify(
pool: &SqlitePool,
identity_hash: Vec<u8>,
auth_verifier: String,
) -> Result<Option<i64>>
pub async fn verify( pool: &SqlitePool, identity_hash: Vec<u8>, auth_verifier: String, ) -> Result<Option<i64>>
Verifies the credential pair (identity_hash and auth_verifier) against the database.
Returns Some(user_id) if a matching user is found, or None if the
credentials do not match any existing record. This is the primary authentication
check used by the login endpoint.
§Errors
- Returns [
sqlx::Error] if the database query fails.
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnsafeUnpin for User
impl UnwindSafe for User
Blanket Implementations§
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> 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