Skip to main content

Module profile

Module profile 

Source
Expand description

个人信息(当前账号资料与密码)的 Leptos server function。 个人信息(当前登录账号的资料与密码)的 Leptos server function。

支撑 /admin/profile 页面:

  • get_profile:读取当前用户公开信息 + ADMIN_* 环境变量是否激活 (激活时邮箱/密码会在重启后被 env 覆盖,页面据此显示提示横幅);
  • update_profile:修改邮箱 / 显示名称 / 头像(username 为登录凭据,只读);
  • change_password:校验当前密码后改密,bump session_generation 使 其他设备会话全部失效,同时刷新当前 token 的会话缓存保留本端登录; 可选同时吊销本人全部 MCP 令牌(令牌是独立凭据,默认不随改密失效)。

资料字段(display_name/avatar_url/email)缓存在 SESSION_CACHE 的 SessionUser 里,故写操作成功后必须同步刷新当前 token 的缓存项, 否则 get_current_user 会持续返回旧值直到缓存 TTL 过期。

Structs§

ChangePassword
Serialized arguments for the change_password server function.
ChangePasswordResponse
修改密码响应。
GetProfile
Serialized arguments for the get_profile server function.
GetProfileResponse
个人信息查询响应。
UpdateProfile
Serialized arguments for the update_profile server function.
UpdateProfileResponse
资料更新响应。

Functions§

change_password
修改当前登录用户的密码。
get_profile
获取当前登录用户的资料。
normalize_avatar_url 🔒
归一化头像 URL:trim 后为空 → None;否则必须为 http(s) 链接或 安全的 /uploads/ 素材路径(与友链头像共用 crate::api::friends::is_local_asset_url), 上限 512 字符。
normalize_display_name 🔒
归一化显示名称:trim 后为空 → None;超过 50 字符报错。
update_profile
更新当前登录用户的资料(邮箱 / 显示名称 / 头像)。