Add optional chaining for response.data.roles access in getUserDetail

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 17:10:12 +08:00
parent 4c2a79a514
commit 91c6f5e54c

View File

@@ -267,7 +267,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
try {
const response = await apiClient.get(apiUserDetail);
this.currentViewingUser = response.data;
this.currentViewingUser.is_admin = response.data.roles.some(role => role.code === 'admin');
this.currentViewingUser.is_admin = response.data.roles?.some(role => role.code === 'admin') ?? false;
return response.status === 200;
} catch (error) {
// No need to show an error, because an error here means the account is unique