pub struct GroupInvite {
pub id: String,
pub group_id: GroupId,
pub token_hash: String,
pub role: GroupRole,
pub created_by: String,
pub created_at: u64,
pub expires_at: u64,
pub max_uses: Option<u32>,
pub current_uses: u32,
pub revoked: bool,
}Expand description
An invitation to join a group.
Invites use a token-based system where:
- An admin creates an invite with a role
- The invite generates a random token
- The token is shared out-of-band (email, Slack, etc.)
- The recipient joins using the token
Fields§
§id: StringUnique identifier for this invite.
group_id: GroupIdThe group this invite is for.
token_hash: StringSHA256 hash of the invite token (never store plaintext).
role: GroupRoleRole to assign when the invite is used.
created_by: StringEmail of the user who created the invite.
created_at: u64When the invite was created (Unix timestamp).
expires_at: u64When the invite expires (Unix timestamp).
max_uses: Option<u32>Maximum number of times this invite can be used.
None means unlimited uses.
current_uses: u32Number of times this invite has been used.
revoked: boolWhether this invite has been revoked.
Implementations§
Source§impl GroupInvite
impl GroupInvite
Sourcepub const DEFAULT_EXPIRY_SECS: u64
pub const DEFAULT_EXPIRY_SECS: u64
Default expiration time in seconds (7 days).
Sourcepub const DEFAULT_MAX_USES: u32 = 1
pub const DEFAULT_MAX_USES: u32 = 1
Default maximum uses for an invite.
Sourcepub fn new(
group_id: GroupId,
role: GroupRole,
created_by: impl Into<String>,
expires_in_secs: Option<u64>,
max_uses: Option<u32>,
) -> (Self, String)
pub fn new( group_id: GroupId, role: GroupRole, created_by: impl Into<String>, expires_in_secs: Option<u64>, max_uses: Option<u32>, ) -> (Self, String)
Creates a new invite for a group.
Returns both the invite and the plaintext token. The token should be shared with the invitee and never stored.
§Arguments
group_id- ID of the group to invite torole- Role to assign when joinedcreated_by- Email of the admin creating the inviteexpires_in_secs- How long until the invite expiresmax_uses- Maximum number of uses (None for unlimited)
Sourcepub fn hash_token(token: &str) -> String
pub fn hash_token(token: &str) -> String
Hashes a token using SHA256.
Sourcepub fn verify_token(&self, token: &str) -> bool
pub fn verify_token(&self, token: &str) -> bool
Verifies a token against this invite’s hash.
Trait Implementations§
Source§impl Clone for GroupInvite
impl Clone for GroupInvite
Source§fn clone(&self) -> GroupInvite
fn clone(&self) -> GroupInvite
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GroupInvite
impl Debug for GroupInvite
Source§impl<'de> Deserialize<'de> for GroupInvite
impl<'de> Deserialize<'de> for GroupInvite
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>,
Auto Trait Implementations§
impl Freeze for GroupInvite
impl RefUnwindSafe for GroupInvite
impl Send for GroupInvite
impl Sync for GroupInvite
impl Unpin for GroupInvite
impl UnwindSafe for GroupInvite
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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>
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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].