Skip to content

Commit 4b4282c

Browse files
authored
fix: 500 on oauth authorize page (#5661)
1 parent 7b34719 commit 4b4282c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

apps/frontend/src/pages/auth/authorize.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<h1>{{ formatMessage(commonMessages.errorLabel) }}</h1>
66
</div>
77
<p>
8-
<span>{{ error.data.error }}: </span>
9-
{{ error.data.description }}
8+
<span>{{ error.data?.error }}: </span>
9+
{{ error.data?.description }}
1010
</p>
1111
</div>
12-
<div v-else class="oauth-items">
12+
<div v-else-if="app && createdBy && authorizationData" class="oauth-items">
1313
<div class="connected-items">
1414
<div class="profile-pics">
1515
<Avatar size="md" :src="app.icon_url" />
@@ -164,24 +164,31 @@ const {
164164
data: authorizationData,
165165
isPending: pending,
166166
error,
167+
suspense: authSusp,
167168
} = useQuery({
168169
queryKey: computed(() => ['authorization', clientId, redirectUri, scope, state]),
169170
queryFn: getFlowIdAuthorization,
170171
enabled: computed(() => !!clientId && !!redirectUri && !!scope),
171172
})
172173
173-
const { data: app } = useQuery({
174+
const { data: app, suspense: appSusp } = useQuery({
174175
queryKey: computed(() => ['oauth/app', clientId]),
175176
queryFn: () => client.labrinth.oauth_internal.getApp(clientId),
176177
enabled: computed(() => !!clientId),
177178
})
178179
179-
const { data: createdBy } = useQuery({
180+
const { data: createdBy, suspense: userSusp } = useQuery({
180181
queryKey: computed(() => ['user', app.value?.created_by]),
181182
queryFn: () => client.labrinth.users_v2.get(app.value.created_by),
182183
enabled: computed(() => !!app.value?.created_by),
183184
})
184185
186+
onServerPrefetch(async () => {
187+
await authSusp()
188+
await appSusp()
189+
await userSusp()
190+
})
191+
185192
const scopeDefinitions = computed(() =>
186193
scopesToDefinitions(BigInt(authorizationData.value?.requested_scopes || 0)),
187194
)

0 commit comments

Comments
 (0)