Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
avdb13 committed Nov 14, 2024
1 parent 949b2b8 commit d5c9f6c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/shared/components/home/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ export async function handleUseOAuthProvider(params: {
`scope=${encodeURIComponent(params.oauth_provider.scopes)}`,
`redirect_uri=${encodeURIComponent(redirectUri)}`,
`state=${state}`,
...(params.oauth_provider.use_pkce
? [
`code_challenge=${encodeURIComponent(code_challenge)}`,
"code_challenge_method=S256",
]
: []),
];

const requestUri =
params.oauth_provider.authorization_endpoint +
"?" +
queryPairs.join("&") +
(params.oauth_provider.use_pkce
? `&code_challenge=${encodeURIComponent(code_challenge)}&code_challenge_method=S256`
: ``);
params.oauth_provider.authorization_endpoint + "?" + queryPairs.join("&");

// store state in local storage
localStorage.setItem(
Expand Down
4 changes: 3 additions & 1 deletion src/shared/components/home/oauth/oauth-callback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ export class OAuthCallback extends Component<OAuthCallbackRouteProps, State> {
} else {
const loginRes = await HttpService.client.authenticateWithOAuth({
code: this.props.code,
pkce_code_verifier: local_oauth_state?.pkce_code_verifier,
oauth_provider_id: local_oauth_state.oauth_provider_id,
redirect_uri: local_oauth_state.redirect_uri,
show_nsfw: local_oauth_state.show_nsfw,
username: local_oauth_state.username,
answer: local_oauth_state.answer,
...(local_oauth_state?.pkce_code_verifier && {
pkce_code_verifier: local_oauth_state.pkce_code_verifier,
}),
});

switch (loginRes.state) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/home/oauth/oauth-providers-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const PRESET_OAUTH_PROVIDERS: ProviderToEdit[] = [
scopes: "openid email",
auto_verify_email: true,
account_linking_enabled: true,
use_pkce: false,
use_pkce: true,
enabled: true,
},
// additional preset providers can be added here
Expand Down

0 comments on commit d5c9f6c

Please sign in to comment.