Skip to main content

SaTokenEvent

Struct SaTokenEvent 

Source
pub struct SaTokenEvent {
    pub event_type: SaTokenEventType,
    pub login_id: String,
    pub token: String,
    pub login_type: String,
    pub timestamp: DateTime<Utc>,
    pub extra: Option<Value>,
}
Expand description

事件数据 | Event data

Fields§

§event_type: SaTokenEventType

事件类型 | Event type

§login_id: String

登录ID | Login ID

§token: String

Token 值 | Token value

§login_type: String

登录类型(如 “default”, “admin” 等)| Login type (e.g. “default”, “admin”)

§timestamp: DateTime<Utc>

事件发生时间 | Event timestamp

§extra: Option<Value>

额外数据(用于扩展)| Extra data (for extension)

Implementations§

Source§

impl SaTokenEvent

Source

pub fn login(login_id: impl Into<String>, token: impl Into<String>) -> Self

创建登录事件 | Create login event

Source

pub fn logout(login_id: impl Into<String>, token: impl Into<String>) -> Self

创建登出事件 | Create logout event

Source

pub fn kick_out(login_id: impl Into<String>, token: impl Into<String>) -> Self

创建踢出下线事件 | Create kick out event

Source

pub fn renew_timeout( login_id: impl Into<String>, token: impl Into<String>, timeout_seconds: i64, ) -> Self

创建 Token 续期事件 | Create token renewal event

§参数 | Parameters
  • login_id: 登录 ID
  • token: Token 值
  • timeout_seconds: 续期后的有效时长(秒)| Renewed validity period (seconds)
Source

pub fn replaced(login_id: impl Into<String>, token: impl Into<String>) -> Self

创建被顶下线事件 | Create replaced event

Source

pub fn banned( login_id: impl Into<String>, service: impl Into<String>, level: i32, ) -> Self

创建被封禁事件 | Create banned event

§参数 | Parameters
  • login_id: 登录 ID
  • service: 封禁服务标识(如 “login”, “comment”)| Service identifier
  • level: 封禁等级 | Ban level
Source

pub fn unbanned(login_id: impl Into<String>, service: impl Into<String>) -> Self

创建解封事件 | Create unbanned event

§参数 | Parameters
  • login_id: 登录 ID
  • service: 解封服务标识 | Service identifier that was unbanned
Source

pub fn open_safe(token: impl Into<String>, service: impl Into<String>) -> Self

创建开启二级认证事件 | Create open safe event

service 存入 extra 字段而非 login_type,避免语义混乱。 Service stored in extra instead of login_type to avoid semantic confusion.

Source

pub fn close_safe(token: impl Into<String>, service: impl Into<String>) -> Self

创建关闭二级认证事件 | Create close safe event

Source

pub fn safe_verify(token: impl Into<String>, service: impl Into<String>) -> Self

创建二级认证校验通过事件 | Create safe verification passed event

Source

pub fn grant_changed( login_id: impl Into<String>, login_type: impl Into<String>, ) -> Self

创建权限/角色变更事件 | Create grant changed event

Source

pub fn with_login_type(self, login_type: impl Into<String>) -> Self

设置登录类型 | Set login type

Source

pub fn with_extra(self, extra: Value) -> Self

设置额外数据 | Set extra data

Trait Implementations§

Source§

impl Clone for SaTokenEvent

Source§

fn clone(&self) -> SaTokenEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SaTokenEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SaTokenEvent

Source§

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 Serialize for SaTokenEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ForyObject for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more