Enhance OAuth flow by updating redirect handling in OAuthController and improving login process in OAuthCallback. Adjust Profile view to notify users upon successful Google account linking. Update mobile app to reflect changes in OAuth identity management with updated data types. This improves user experience and feedback during the OAuth process.

This commit is contained in:
Torsten Schulz (local)
2026-05-15 09:11:43 +02:00
parent 52719d5625
commit 58dd657ac1
4 changed files with 22 additions and 8 deletions

View File

@@ -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 () => {
}
</style>

View File

@@ -125,12 +125,15 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useAuthStore } from '../stores/authStore'
import { useModal } from '../composables/useModal'
import Modal from '../components/Modal.vue'
import { API_BASE_URL } from '@/config/api'
const API_URL = API_BASE_URL
const route = useRoute()
const router = useRouter()
const authStore = useAuthStore()
const availableStates = ref([])
const identities = ref([])
@@ -305,6 +308,11 @@ onMounted(async () => {
loadProfile(),
loadIdentities()
])
if (route.query.oauthLinked === 'google') {
await alert('Google-Konto wurde erfolgreich verknüpft', 'Erfolg')
router.replace('/settings/profile')
}
})
</script>