diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ba02e5b..01fbe93 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -104,10 +104,39 @@ export default { this.$router.push(`/showclub/${newVal}`); } }, + isAuthenticated(newVal) { + if (newVal) { + // Benutzer hat sich eingeloggt - Daten laden + this.loadUserData(); + } else { + // Benutzer hat sich ausgeloggt - Daten zurücksetzen + this.setClubs([]); + this.selectedClub = null; + if (this.sessionInterval) { + clearInterval(this.sessionInterval); + this.sessionInterval = null; + } + } + }, }, methods: { ...mapActions(['setCurrentClub', 'setClubs', 'logout']), + async loadUserData() { + try { + const response = await apiClient.get('/clubs'); + this.setClubs(response.data); + if (this.currentClub) { + this.selectedClub = this.currentClub; + } + this.checkSession(); + this.sessionInterval = setInterval(this.checkSession, 5000); + } catch (error) { + this.setClubs([]); + this.selectedClub = null; + } + }, + loadClub() { this.setCurrentClub(this.currentClub); this.$router.push(`/showclub/${this.currentClub}`); @@ -134,17 +163,20 @@ export default { } }, async mounted() { - try { - const response = await apiClient.get('/clubs'); - this.setClubs(response.data); - if (this.currentClub) { - this.selectedClub = this.currentClub; + // Nur Daten laden, wenn der Benutzer authentifiziert ist + if (this.isAuthenticated) { + try { + const response = await apiClient.get('/clubs'); + this.setClubs(response.data); + if (this.currentClub) { + this.selectedClub = this.currentClub; + } + this.checkSession(); + this.sessionInterval = setInterval(this.checkSession, 5000); + } catch (error) { + this.setClubs([]); + this.selectedClub = null; } - this.checkSession(); - this.sessionInterval = setInterval(this.checkSession, 5000); - } catch (error) { - this.setClubs([]); - this.selectedClub = null; } }, beforeUnmount() { diff --git a/frontend/src/assets/css/components.scss b/frontend/src/assets/css/components.scss index 2e28291..46db46e 100644 --- a/frontend/src/assets/css/components.scss +++ b/frontend/src/assets/css/components.scss @@ -498,3 +498,34 @@ padding: 0.875rem; } } + +/* Login und Registrierungslinks */ +.login-link, +.register-link { + margin-top: 1.5rem; + text-align: center; + padding: 1rem; + background-color: var(--background-light); + border-radius: var(--border-radius); + border: 1px solid var(--border-color); +} + +.login-link p, +.register-link p { + margin: 0; + color: var(--text-muted); +} + +.login-link a, +.register-link a { + color: var(--primary-color); + text-decoration: none; + font-weight: 500; + transition: color 0.2s ease; +} + +.login-link a:hover, +.register-link a:hover { + color: var(--primary-dark); + text-decoration: underline; +} diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index ce87e2c..4c40ab3 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -6,6 +6,9 @@ +
Noch kein Konto?
Bereits ein Konto?