|
11 | 11 | </div> |
12 | 12 | <section class="flex flex-col gap-2.5"> |
13 | 13 | <ButtonLink |
14 | | - :href="getAuthUrl('google', redirectTarget, requestsAppSession)" |
| 14 | + :disabled="!oauthCodeChallenge" |
| 15 | + :href="providerAuthUrl('google')" |
15 | 16 | @click="onOAuthProviderClick('google', $event)" |
16 | 17 | > |
17 | 18 | <GoogleColorIcon /> |
18 | 19 | <span>{{ formatMessage(messages.continueWithProvider, { provider: 'Google' }) }}</span> |
19 | 20 | </ButtonLink> |
20 | 21 | <ButtonLink |
21 | | - :href="getAuthUrl('microsoft', redirectTarget, requestsAppSession)" |
| 22 | + :disabled="!oauthCodeChallenge" |
| 23 | + :href="providerAuthUrl('microsoft')" |
22 | 24 | @click="onOAuthProviderClick('microsoft', $event)" |
23 | 25 | > |
24 | 26 | <MicrosoftColorIcon /> |
25 | 27 | <span>{{ formatMessage(messages.continueWithProvider, { provider: 'Microsoft' }) }}</span> |
26 | 28 | </ButtonLink> |
27 | 29 | <ButtonLink |
28 | | - :href="getAuthUrl('discord', redirectTarget, requestsAppSession)" |
| 30 | + :disabled="!oauthCodeChallenge" |
| 31 | + :href="providerAuthUrl('discord')" |
29 | 32 | @click="onOAuthProviderClick('discord', $event)" |
30 | 33 | > |
31 | 34 | <DiscordColorIcon /> |
32 | 35 | <span>{{ formatMessage(messages.continueWithProvider, { provider: 'Discord' }) }}</span> |
33 | 36 | </ButtonLink> |
34 | 37 | <template v-if="showOtherOptions"> |
35 | 38 | <ButtonLink |
36 | | - :href="getAuthUrl('github', redirectTarget, requestsAppSession)" |
| 39 | + :disabled="!oauthCodeChallenge" |
| 40 | + :href="providerAuthUrl('github')" |
37 | 41 | @click="onOAuthProviderClick('github', $event)" |
38 | 42 | > |
39 | 43 | <GitHubColorIcon /> |
40 | 44 | <span>{{ formatMessage(messages.continueWithProvider, { provider: 'GitHub' }) }}</span> |
41 | 45 | </ButtonLink> |
42 | 46 | <ButtonLink |
43 | | - :href="getAuthUrl('gitlab', redirectTarget, requestsAppSession)" |
| 47 | + :disabled="!oauthCodeChallenge" |
| 48 | + :href="providerAuthUrl('gitlab')" |
44 | 49 | @click="onOAuthProviderClick('gitlab', $event)" |
45 | 50 | > |
46 | 51 | <GitLabColorIcon /> |
47 | 52 | <span>{{ formatMessage(messages.continueWithProvider, { provider: 'GitLab' }) }}</span> |
48 | 53 | </ButtonLink> |
49 | 54 | <ButtonLink |
50 | | - :href="getAuthUrl('steam', redirectTarget, requestsAppSession)" |
| 55 | + :disabled="!oauthCodeChallenge" |
| 56 | + :href="providerAuthUrl('steam')" |
51 | 57 | @click="onOAuthProviderClick('steam', $event)" |
52 | 58 | > |
53 | 59 | <SteamColorIcon /> |
@@ -166,6 +172,7 @@ import { getAuthUrl } from '@/composables/auth.ts' |
166 | 172 | import { isAuthEmbedded, useAuthNavigation } from '@/composables/auth-modal.ts' |
167 | 173 | import { useProviderOpening } from '@/composables/external-auth.ts' |
168 | 174 | import { isLauncherProtocolV2 } from '@/composables/launcher-auth.ts' |
| 175 | +import { useOAuthCodeChallenge } from '@/composables/oauth-pkce.ts' |
169 | 176 | import type { OAuthProviderId } from '@/composables/oauth-providers.ts' |
170 | 177 |
|
171 | 178 | interface Props { |
@@ -199,13 +206,25 @@ function openSignIn() { |
199 | 206 | }) |
200 | 207 | } |
201 | 208 |
|
| 209 | +const oauthCodeChallenge = useOAuthCodeChallenge() |
| 210 | +
|
| 211 | +function providerAuthUrl(provider: string) { |
| 212 | + const challenge = oauthCodeChallenge.value |
| 213 | + if (!challenge) { |
| 214 | + return undefined |
| 215 | + } |
| 216 | + return getAuthUrl(provider, redirectTarget, requestsAppSession.value, challenge) |
| 217 | +} |
| 218 | +
|
202 | 219 | const onOAuthProviderClick = (provider: OAuthProviderId, event: MouseEvent) => { |
203 | | - beginProviderHandoff( |
204 | | - provider, |
205 | | - event, |
206 | | - getAuthUrl(provider, redirectTarget, requestsAppSession.value), |
207 | | - { skip: Boolean(routeQuery.launcher || requestsAppSession.value) }, |
208 | | - ) |
| 220 | + const url = providerAuthUrl(provider) |
| 221 | + if (!url) { |
| 222 | + event.preventDefault() |
| 223 | + return |
| 224 | + } |
| 225 | + beginProviderHandoff(provider, event, url, { |
| 226 | + skip: Boolean(routeQuery.launcher || requestsAppSession.value), |
| 227 | + }) |
209 | 228 | } |
210 | 229 |
|
211 | 230 | const { formatMessage } = useVIntl() |
|
0 commit comments