发布 0.1.0:通知渠道、告警规则与多项体验修复
This commit is contained in:
+25
-14
@@ -5,6 +5,7 @@ import type {
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
OAuthSettings,
|
||||
SessionRefresh,
|
||||
TotpSetup,
|
||||
TotpStatus,
|
||||
UpdateCredentialsRequest,
|
||||
@@ -26,6 +27,14 @@ export function logout(): Promise<void> {
|
||||
return request('/auth/logout', { method: 'POST' })
|
||||
}
|
||||
|
||||
// ---- 会话 ----
|
||||
|
||||
/** 撤销全部会话:旧 token 全部失效,响应带操作者的新会话 */
|
||||
export function revokeSessions(): Promise<SessionRefresh> {
|
||||
if (mockOn) return mocked({ token: 'mock-token-2', expiresAt: '2099-01-01T00:00:00Z' }, 300)
|
||||
return request('/auth/revoke-sessions', { method: 'POST' })
|
||||
}
|
||||
|
||||
// ---- 登录凭据 ----
|
||||
|
||||
export function getCredentials(): Promise<CredentialsInfo> {
|
||||
@@ -33,15 +42,15 @@ export function getCredentials(): Promise<CredentialsInfo> {
|
||||
return request('/auth/credentials')
|
||||
}
|
||||
|
||||
/** 修改用户名 / 密码;成功后旧 token 随即失效,调用方应登出重登 */
|
||||
export function updateCredentials(body: UpdateCredentialsRequest): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 400)
|
||||
/** 修改用户名 / 密码;成功后旧 token 全部失效,响应带操作者的新会话 */
|
||||
export function updateCredentials(body: UpdateCredentialsRequest): Promise<SessionRefresh> {
|
||||
if (mockOn) return mocked({ token: 'mock-token-2', expiresAt: '2099-01-01T00:00:00Z' }, 400)
|
||||
return request('/auth/credentials', { method: 'PUT', body })
|
||||
}
|
||||
|
||||
/** 保存密码登录禁用开关;开启要求至少绑定一个外部身份(后端 409) */
|
||||
export function updatePasswordLogin(disabled: boolean): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 300)
|
||||
/** 保存密码登录禁用开关;成功后旧 token 全部失效,响应带新会话 */
|
||||
export function updatePasswordLogin(disabled: boolean): Promise<SessionRefresh> {
|
||||
if (mockOn) return mocked({ token: 'mock-token-2', expiresAt: '2099-01-01T00:00:00Z' }, 300)
|
||||
return request('/auth/password-login', { method: 'PUT', body: { disabled } })
|
||||
}
|
||||
|
||||
@@ -62,14 +71,15 @@ export function setupTotp(): Promise<TotpSetup> {
|
||||
return request('/auth/totp/setup', { method: 'POST' })
|
||||
}
|
||||
|
||||
export function activateTotp(code: string): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 300)
|
||||
/** 激活两步验证;成功后旧 token 全部失效,响应带新会话 */
|
||||
export function activateTotp(code: string): Promise<SessionRefresh> {
|
||||
if (mockOn) return mocked({ token: 'mock-token-2', expiresAt: '2099-01-01T00:00:00Z' }, 300)
|
||||
return request('/auth/totp/activate', { method: 'POST', body: { code } })
|
||||
}
|
||||
|
||||
/** 停用两步验证;密码或当前验证码任一确认 */
|
||||
export function disableTotp(body: { password?: string; code?: string }): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 300)
|
||||
/** 停用两步验证;密码或当前验证码任一确认,响应带新会话 */
|
||||
export function disableTotp(body: { password?: string; code?: string }): Promise<SessionRefresh> {
|
||||
if (mockOn) return mocked({ token: 'mock-token-2', expiresAt: '2099-01-01T00:00:00Z' }, 300)
|
||||
return request('/auth/totp/disable', { method: 'POST', body })
|
||||
}
|
||||
|
||||
@@ -92,7 +102,7 @@ export function getOauthProviders(): Promise<{
|
||||
return request('/auth/oauth/providers')
|
||||
}
|
||||
|
||||
/** 获取授权跳转 URL;bind 模式要求已登录(带 JWT) */
|
||||
/** 获取授权跳转 URL;bind 模式要求已登录 */
|
||||
export function getOauthAuthorizeUrl(
|
||||
provider: string,
|
||||
mode: 'login' | 'bind',
|
||||
@@ -111,8 +121,9 @@ export function listIdentities(): Promise<{ items: UserIdentityInfo[] }> {
|
||||
return request('/auth/identities')
|
||||
}
|
||||
|
||||
export function unbindIdentity(id: number): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 300)
|
||||
/** 解绑外部身份;成功后旧 token 全部失效,响应带新会话 */
|
||||
export function unbindIdentity(id: number): Promise<SessionRefresh> {
|
||||
if (mockOn) return mocked({ token: 'mock-token-2', expiresAt: '2099-01-01T00:00:00Z' }, 300)
|
||||
return request(`/auth/identities/${id}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user