mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
feat(user_ldap): Adapt frontend to call new endpoints
Signed-off-by: Louis Chemineau <louis@chmn.me> Signed-off-by: Louis Chmn <louis@chmn.me>
This commit is contained in:
parent
a0e5548e49
commit
777c729f68
6 changed files with 21 additions and 21 deletions
|
|
@ -30,6 +30,7 @@ return array(
|
|||
'OCA\\User_LDAP\\ConnectionFactory' => $baseDir . '/../lib/ConnectionFactory.php',
|
||||
'OCA\\User_LDAP\\Controller\\ConfigAPIController' => $baseDir . '/../lib/Controller/ConfigAPIController.php',
|
||||
'OCA\\User_LDAP\\Controller\\RenewPasswordController' => $baseDir . '/../lib/Controller/RenewPasswordController.php',
|
||||
'OCA\\User_LDAP\\Controller\\WizardController' => $baseDir . '/../lib/Controller/WizardController.php',
|
||||
'OCA\\User_LDAP\\DataCollector\\LdapDataCollector' => $baseDir . '/../lib/DataCollector/LdapDataCollector.php',
|
||||
'OCA\\User_LDAP\\Db\\GroupMembership' => $baseDir . '/../lib/Db/GroupMembership.php',
|
||||
'OCA\\User_LDAP\\Db\\GroupMembershipMapper' => $baseDir . '/../lib/Db/GroupMembershipMapper.php',
|
||||
|
|
@ -95,5 +96,6 @@ return array(
|
|||
'OCA\\User_LDAP\\User_LDAP' => $baseDir . '/../lib/User_LDAP.php',
|
||||
'OCA\\User_LDAP\\User_Proxy' => $baseDir . '/../lib/User_Proxy.php',
|
||||
'OCA\\User_LDAP\\Wizard' => $baseDir . '/../lib/Wizard.php',
|
||||
'OCA\\User_LDAP\\WizardFactory' => $baseDir . '/../lib/WizardFactory.php',
|
||||
'OCA\\User_LDAP\\WizardResult' => $baseDir . '/../lib/WizardResult.php',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class ComposerStaticInitUser_LDAP
|
|||
'OCA\\User_LDAP\\ConnectionFactory' => __DIR__ . '/..' . '/../lib/ConnectionFactory.php',
|
||||
'OCA\\User_LDAP\\Controller\\ConfigAPIController' => __DIR__ . '/..' . '/../lib/Controller/ConfigAPIController.php',
|
||||
'OCA\\User_LDAP\\Controller\\RenewPasswordController' => __DIR__ . '/..' . '/../lib/Controller/RenewPasswordController.php',
|
||||
'OCA\\User_LDAP\\Controller\\WizardController' => __DIR__ . '/..' . '/../lib/Controller/WizardController.php',
|
||||
'OCA\\User_LDAP\\DataCollector\\LdapDataCollector' => __DIR__ . '/..' . '/../lib/DataCollector/LdapDataCollector.php',
|
||||
'OCA\\User_LDAP\\Db\\GroupMembership' => __DIR__ . '/..' . '/../lib/Db/GroupMembership.php',
|
||||
'OCA\\User_LDAP\\Db\\GroupMembershipMapper' => __DIR__ . '/..' . '/../lib/Db/GroupMembershipMapper.php',
|
||||
|
|
@ -110,6 +111,7 @@ class ComposerStaticInitUser_LDAP
|
|||
'OCA\\User_LDAP\\User_LDAP' => __DIR__ . '/..' . '/../lib/User_LDAP.php',
|
||||
'OCA\\User_LDAP\\User_Proxy' => __DIR__ . '/..' . '/../lib/User_Proxy.php',
|
||||
'OCA\\User_LDAP\\Wizard' => __DIR__ . '/..' . '/../lib/Wizard.php',
|
||||
'OCA\\User_LDAP\\WizardFactory' => __DIR__ . '/..' . '/../lib/WizardFactory.php',
|
||||
'OCA\\User_LDAP\\WizardResult' => __DIR__ . '/..' . '/../lib/WizardResult.php',
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ async function getUserLoginFilter() {
|
|||
*/
|
||||
async function verifyLoginName() {
|
||||
try {
|
||||
const response = await callWizard('testLoginName', props.configId, { ldap_test_loginname: testUsername.value })
|
||||
const response = await callWizard('testLoginName', props.configId, { loginName: testUsername.value })
|
||||
|
||||
const testLoginName = response.changes!.ldap_test_loginname as number
|
||||
const testEffectiveFilter = response.changes!.ldap_test_effective_filter as string
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ const ldapConfigsStore = useLDAPConfigsStore()
|
|||
const { updatingConfig } = storeToRefs(ldapConfigsStore)
|
||||
|
||||
const loading = ref(false)
|
||||
const result = ref<{ message: string, status: 'error' | 'success' } | null>(null)
|
||||
const isValide = computed(() => result.value?.status === 'success')
|
||||
const result = ref<{ success: boolean, message: string } | null>(null)
|
||||
const isValide = computed(() => result.value?.success)
|
||||
|
||||
watch(updatingConfig, () => {
|
||||
result.value = null
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ export async function copyConfig(configId: string) {
|
|||
params.set('copyConfig', configId)
|
||||
|
||||
const response = await axios.post(
|
||||
path.join(AJAX_ENDPOINT, 'getNewServerConfigPrefix.php'),
|
||||
generateOcsUrl('apps/user_ldap/api/v1/config/{configId}/copy', { configId }),
|
||||
params,
|
||||
) as AxiosResponse<{ status: 'error' | 'success', configPrefix: string }>
|
||||
) as AxiosResponse<OCSResponse<{ configID: string }>>
|
||||
|
||||
logger.debug('Created configuration', { configId: response.data.configPrefix })
|
||||
return response.data.configPrefix
|
||||
logger.debug('Created configuration', { configId: response.data.ocs.data.configID })
|
||||
return response.data.ocs.data.configID
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,16 +119,14 @@ export async function deleteConfig(configId: string): Promise<boolean> {
|
|||
*/
|
||||
export async function testConfiguration(configId: string) {
|
||||
const params = new FormData()
|
||||
params.set('ldap_serverconfig_chooser', configId)
|
||||
|
||||
const response = await axios.post(
|
||||
path.join(AJAX_ENDPOINT, 'testConfiguration.php'),
|
||||
params,
|
||||
) as AxiosResponse<{ message: string, status: 'error' | 'success' }>
|
||||
generateOcsUrl('apps/user_ldap/api/v1/config/{configId}/test', { configId }),
|
||||
) as AxiosResponse<OCSResponse<{ success: boolean, message: string }>>
|
||||
|
||||
logger.debug(`Configuration is ${response.data.status === 'success' ? 'valide' : 'invalide'}`, { configId, params, response })
|
||||
logger.debug(`Configuration is ${response.data.ocs.data.success ? 'valide' : 'invalide'}`, { configId, params, response })
|
||||
|
||||
return response.data
|
||||
return response.data.ocs.data
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -168,27 +166,25 @@ export async function clearMapping(subject: 'user' | 'group') {
|
|||
*/
|
||||
export async function callWizard(action: WizardAction, configId: string, extraParams: Record<string, string> = {}) {
|
||||
const params = new FormData()
|
||||
params.set('action', action)
|
||||
params.set('ldap_serverconfig_chooser', configId)
|
||||
|
||||
Object.entries(extraParams).forEach(([key, value]) => {
|
||||
params.set(key, value)
|
||||
})
|
||||
|
||||
const response = await axios.post(
|
||||
path.join(AJAX_ENDPOINT, 'wizard.php'),
|
||||
generateOcsUrl('apps/user_ldap/api/v1/wizard/{configId}/{action}', { configId, action }),
|
||||
params,
|
||||
) as AxiosResponse<{ status: 'error', message?: string } | { status: 'success', changes?: Record<string, unknown>, options?: Record<string, []> }>
|
||||
) as AxiosResponse<OCSResponse<{ changes?: Record<string, unknown>, options?: Record<string, []> }>>
|
||||
|
||||
logger.debug(`Called wizard action: ${action}`, { configId, params, response })
|
||||
|
||||
if (response.data.status === 'error') {
|
||||
const message = response.data.message ?? t('user_ldap', 'An error occurred')
|
||||
if (response.data.ocs.meta.status === 'failure') {
|
||||
const message = response.data.ocs.meta.message ?? t('user_ldap', 'An error occurred')
|
||||
showError(message)
|
||||
throw new Error(message)
|
||||
}
|
||||
|
||||
return response.data
|
||||
return response.data.ocs.data
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export const useLDAPConfigsStore = defineStore('ldap-configs', () => {
|
|||
|
||||
;(async () => {
|
||||
updatingConfig.value++
|
||||
await callWizard('save', configId, { cfgkey: property, cfgval: newValue })
|
||||
await callWizard('save', configId, { key: property, val: newValue })
|
||||
updatingConfig.value--
|
||||
|
||||
if (postSetHooks[property] !== undefined) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue