fix(club): enhance error handling in loadClub method

- Improved error handling in the loadClub method to check response status directly, ensuring proper fallback club data is used when access is denied.
- Updated logic to throw an error for unexpected response statuses, enhancing user feedback and robustness in access management.
This commit is contained in:
Torsten Schulz (local)
2026-02-04 13:42:33 +01:00
parent 2a7694617b
commit f9a63a13ce

View File

@@ -130,18 +130,20 @@ export default {
const clubId = this.getClubId();
this.accessRequested = false;
const response = await apiClient.get(`/clubs/${clubId}`);
this.club = response.data || { name: '' };
this.accessAllowed = true;
} catch (error) {
// Kein Zugriff: Status vom Backend nutzen (requested/notrequested)
if (error?.response?.status === 403 && error?.response?.data?.status) {
const clubId = this.getClubId();
// apiClient behandelt 4xx als "erfolgreich" -> Status selbst prüfen
if (response.status === 403 && response.data?.status) {
const club = this.clubs.find(c => String(c.id) === String(clubId));
this.club = club || { name: '' };
this.accessAllowed = false;
this.accessRequested = error.response.data.status === 'requested';
this.accessRequested = response.data.status === 'requested';
return;
}
if (response.status >= 400) {
throw new Error('club_access_error');
}
this.club = response.data || { name: '' };
this.accessAllowed = true;
} catch (error) {
this.accessAllowed = false;
const message = safeErrorMessage(error, this.$t('club.accessDenied'));
await this.showInfo(this.$t('messages.error'), message, '', 'error');