Skip to content

Commit

Permalink
a few more
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasballinger committed Dec 20, 2024
1 parent 813c3b0 commit ae6dfd8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/nextjs/server/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function proxyAuthActionToConvex(
// Do not require auth when refreshing tokens or validating a code since they
// are steps in the auth flow.
const fetchActionAuthOptions =
args.refreshToken !== undefined || args.params?.code !== undefined
args.refreshToken !== undefined || args.params?.cvxAuthCode !== undefined
? {}
: { token };
try {
Expand Down
6 changes: 3 additions & 3 deletions src/nextjs/server/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export async function handleAuthenticationInRequest(
const refreshTokens = await getRefreshedTokens(verbose);

// Handle code exchange for OAuth and magic links via server-side redirect
const code = requestUrl.searchParams.get("cvxAuthCode");
const cvxAuthCode = requestUrl.searchParams.get("cvxAuthCode");
if (
code &&
cvxAuthCode &&
request.method === "GET" &&
request.headers.get("accept")?.includes("text/html")
) {
Expand All @@ -39,7 +39,7 @@ export async function handleAuthenticationInRequest(
try {
const result = await fetchAction(
"auth:signIn" as unknown as SignInAction,
{ params: { code }, verifier },
{ params: { cvxAuthCode }, verifier },
);
if (result.tokens === undefined) {
throw new Error("Invalid `signIn` action result for code exchange");
Expand Down
3 changes: 2 additions & 1 deletion src/server/implementation/signIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ async function handleEmailAndPhoneProvider(
| { kind: "started"; started: true }
| { kind: "signedIn"; signedIn: SessionInfoWithTokens }
> {
if (args.params?.code !== undefined) {
// TODO this this flow
if (args.params?.cvxAuthCode !== undefined) {
const result = await callVerifyCodeAndSignIn(ctx, {
params: args.params,
provider: provider.id,
Expand Down
1 change: 1 addition & 0 deletions src/server/implementation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const authTables = {
* - OTP tokens
* - magic link tokens
* - OAuth codes
* Let's call all of these "cvxAuthCodes" to distinguish them from oauth code= param.
*/
authVerificationCodes: defineTable({
accountId: v.id("authAccounts"),
Expand Down

0 comments on commit ae6dfd8

Please sign in to comment.