+22
-25
@@ -129,34 +129,31 @@ export function unbindIdentity(id: number): Promise<SessionRefresh> {
|
||||
|
||||
// ---- OAuth provider 配置(设置页) ----
|
||||
|
||||
const mockOauth: OAuthSettings = {
|
||||
oidcIssuer: '',
|
||||
oidcClientId: '',
|
||||
oidcSecretSet: false,
|
||||
oidcDisplayName: '',
|
||||
oidcDisabled: false,
|
||||
githubClientId: '',
|
||||
githubSecretSet: false,
|
||||
githubDisplayName: '',
|
||||
githubDisabled: false,
|
||||
}
|
||||
|
||||
export function getOAuthSettings(): Promise<OAuthSettings> {
|
||||
if (mockOn)
|
||||
return mocked({
|
||||
oidcIssuer: '',
|
||||
oidcClientId: '',
|
||||
oidcSecretSet: false,
|
||||
oidcDisplayName: '',
|
||||
oidcDisabled: false,
|
||||
githubClientId: '',
|
||||
githubSecretSet: false,
|
||||
githubDisplayName: '',
|
||||
githubDisabled: false,
|
||||
})
|
||||
if (mockOn) return mocked({ ...mockOauth })
|
||||
return request('/settings/oauth')
|
||||
}
|
||||
|
||||
/** 字段补丁部分更新:缺省字段沿用现值,并发编辑不同 provider 互不回滚 */
|
||||
export function updateOAuthSettings(body: UpdateOAuthRequest): Promise<OAuthSettings> {
|
||||
if (mockOn)
|
||||
return mocked({
|
||||
oidcIssuer: body.oidcIssuer,
|
||||
oidcClientId: body.oidcClientId,
|
||||
oidcSecretSet: !!body.oidcClientSecret,
|
||||
oidcDisplayName: body.oidcDisplayName,
|
||||
oidcDisabled: body.oidcDisabled,
|
||||
githubClientId: body.githubClientId,
|
||||
githubSecretSet: !!body.githubClientSecret,
|
||||
githubDisplayName: body.githubDisplayName,
|
||||
githubDisabled: body.githubDisabled,
|
||||
})
|
||||
return request('/settings/oauth', { method: 'PUT', body })
|
||||
if (mockOn) {
|
||||
const { oidcClientSecret, githubClientSecret, ...rest } = body
|
||||
Object.assign(mockOauth, Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== undefined)))
|
||||
if (oidcClientSecret !== undefined) mockOauth.oidcSecretSet = oidcClientSecret !== ''
|
||||
if (githubClientSecret !== undefined) mockOauth.githubSecretSet = githubClientSecret !== ''
|
||||
return mocked({ ...mockOauth })
|
||||
}
|
||||
return request('/settings/oauth', { method: 'PATCH', body })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user