fix: roles error handling on admin ui

This commit is contained in:
2026-01-26 12:27:35 +02:00
parent 66e03c3a5d
commit a2e44af6bd
2 changed files with 12 additions and 1 deletions

View File

@@ -29,6 +29,10 @@
{{ strings.userRolesHelp }}
</NcNoteCard>
<NcNoteCard v-if="rolesError" type="error">
{{ rolesError }}
</NcNoteCard>
<div class="settings-section-content">
<div class="user-role-form">
<div class="field-row">
@@ -111,6 +115,7 @@ export default {
// User roles
rolesLoading: true,
rolesError: null,
roles: [],
userId: '',
selectedRole: null,
@@ -157,10 +162,12 @@ export default {
async fetchRoles() {
try {
this.rolesLoading = true
this.rolesError = null
const resp = await ocs.get('/admin/roles')
this.roles = resp.data.roles
} catch (e) {
console.error('Failed to fetch roles', e)
this.rolesError = e.response?.data?.message || t('forum', 'Failed to fetch roles')
} finally {
this.rolesLoading = false
}

View File

@@ -16,7 +16,11 @@ ocs.interceptors.response.use(
if (ocsResponse !== undefined) {
// Extract data from OCS response, falling back to meta message for errors
const ocsData = ocsResponse.data
if (ocsData !== undefined && ocsData !== null) {
const isEmpty =
ocsData === undefined ||
ocsData === null ||
(Array.isArray(ocsData) && ocsData.length === 0)
if (!isEmpty) {
error.response.data = ocsData
} else if (ocsResponse.meta?.message) {
// For OCS errors that only have meta message (no data)