diff --git a/backend/src/controllers/OAuthController.js b/backend/src/controllers/OAuthController.js index b351b0a..d937440 100644 --- a/backend/src/controllers/OAuthController.js +++ b/backend/src/controllers/OAuthController.js @@ -76,7 +76,14 @@ class OAuthController { return res.redirect(`${target}?${params.toString()}`); } - return res.redirect(`${target}?token=${encodeURIComponent(authResult.token)}`); + const params = new URLSearchParams({ + token: authResult.token + }); + if (state.mode === 'link') { + params.set('linked', result.provider); + } + + return res.redirect(`${target}?${params.toString()}`); } catch (callbackError) { console.error('Google OAuth Callback-Verarbeitung fehlgeschlagen:', callbackError); return res.redirect(`${process.env.FRONTEND_URL || 'http://localhost:5010'}/login?error=oauth_failed`); @@ -169,4 +176,3 @@ class OAuthController { module.exports = new OAuthController(); - diff --git a/frontend/src/views/OAuthCallback.vue b/frontend/src/views/OAuthCallback.vue index 346a743..1328d76 100644 --- a/frontend/src/views/OAuthCallback.vue +++ b/frontend/src/views/OAuthCallback.vue @@ -44,12 +44,12 @@ const password = ref('') const linking = ref(false) const errorMessage = ref('') -async function finishLogin(token) { +async function finishLogin(token, redirectTarget = '/') { authStore.saveToken(token) await authStore.fetchCurrentUser() status.value = 'Login erfolgreich! Sie werden weitergeleitet...' setTimeout(() => { - router.push('/') + router.push(redirectTarget) }, 1000) } @@ -71,7 +71,7 @@ async function linkExistingAccount() { throw new Error(result.error || 'Verknüpfung fehlgeschlagen') } pendingToken.value = '' - await finishLogin(result.token) + await finishLogin(result.token, '/settings/profile?oauthLinked=google') } catch (error) { errorMessage.value = error.message || 'Verknüpfung fehlgeschlagen' } finally { @@ -83,6 +83,7 @@ onMounted(async () => { const token = route.query.token const error = route.query.error const pending = route.query.pending + const linked = route.query.linked if (error) { status.value = 'OAuth-Login fehlgeschlagen' @@ -101,7 +102,7 @@ onMounted(async () => { if (token) { try { - await finishLogin(token) + await finishLogin(token, linked ? '/settings/profile?oauthLinked=google' : '/') } catch (err) { status.value = 'Fehler beim Login' setTimeout(() => { @@ -180,4 +181,3 @@ onMounted(async () => { } - diff --git a/frontend/src/views/Profile.vue b/frontend/src/views/Profile.vue index f9effde..8c0a1f8 100644 --- a/frontend/src/views/Profile.vue +++ b/frontend/src/views/Profile.vue @@ -125,12 +125,15 @@ diff --git a/mobile-app/composeApp/src/main/kotlin/de/tsschulz/timeclock/data/api/SettingsDtos.kt b/mobile-app/composeApp/src/main/kotlin/de/tsschulz/timeclock/data/api/SettingsDtos.kt index 0fe4354..3111de4 100644 --- a/mobile-app/composeApp/src/main/kotlin/de/tsschulz/timeclock/data/api/SettingsDtos.kt +++ b/mobile-app/composeApp/src/main/kotlin/de/tsschulz/timeclock/data/api/SettingsDtos.kt @@ -47,7 +47,7 @@ data class OAuthIdentitiesResponse( data class OAuthIdentityDto( val provider: String, val identity: String? = null, - val id: String? = null, + val id: Int? = null, ) @Serializable