fix(auth): relax keycloak audience check and auto-redirect logged-in user

This commit is contained in:
Chris
2026-04-01 01:48:06 +08:00
parent f0fd5d6e68
commit a9c7cb5f39
2 changed files with 16 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ class Settings(BaseSettings):
@property
def idp_audience(self) -> str:
if self.use_keycloak:
return self.keycloak_audience or self.keycloak_client_id
return self.keycloak_audience
return self.authentik_audience or self.authentik_client_id
@property

View File

@@ -35,11 +35,14 @@
</template>
<script setup>
import { ref } from 'vue'
import { useRoute } from 'vue-router'
import { onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getOidcAuthorizeUrl } from '@/api/auth'
import { useAuthStore } from '@/stores/auth'
const route = useRoute()
const router = useRouter()
const authStore = useAuthStore()
const loginLoading = ref(false)
const error = ref('')
@@ -49,6 +52,16 @@ function getPostLoginRedirect() {
return typeof redirect === 'string' ? redirect : '/me'
}
onMounted(async () => {
if (!authStore.isLoggedIn) return
try {
await authStore.fetchMe()
router.replace(getPostLoginRedirect())
} catch (_err) {
authStore.logout()
}
})
async function handleLogin() {
loginLoading.value = true
error.value = ''