taolib.testing.oauth.repository.session_repo#

OAuth 会话 Repository 模块。

提供 OAuth 会话的数据访问操作。

Classes#

OAuthSessionRepository

OAuth 会话数据访问层。

Module Contents#

class taolib.testing.oauth.repository.session_repo.OAuthSessionRepository(collection)#

Bases: taolib.testing._base.repository.AsyncRepository[taolib.testing.oauth.models.session.OAuthSessionDocument]

OAuth 会话数据访问层。

async find_active_sessions(user_id: str) list[taolib.testing.oauth.models.session.OAuthSessionDocument]#

获取用户的所有活跃会话。

参数:

user_id -- 用户 ID

返回:

活跃会话列表

async deactivate_session(session_id: str) bool#

停用指定会话。

参数:

session_id -- 会话 ID

返回:

是否成功停用

async deactivate_all_for_user(user_id: str) int#

停用用户的所有会话。

参数:

user_id -- 用户 ID

返回:

停用的会话数量

async touch_session(session_id: str) None#

更新会话的最后活跃时间。

参数:

session_id -- 会话 ID

async create_indexes() None#

创建 MongoDB 索引。