Skip to content

Commit

Permalink
Drop cookie on login
Browse files Browse the repository at this point in the history
  • Loading branch information
broody committed May 24, 2024
1 parent 9b1f631 commit 93f3031
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
12 changes: 1 addition & 11 deletions examples/starknet-react-next/src/components/StarknetProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,7 @@ export function StarknetProvider({ children }: PropsWithChildren) {
);
}

const url =
!process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL ||
process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL.split(".")[0] ===
"cartridge-starknet-react-next"
? process.env.XFRAME_URL
: "https://" +
(process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL ?? "").replace(
"cartridge-starknet-react-next",
"keychain",
);

const url = "https://keychain-git-login-cookie.preview.cartridge.gg";
const connectors = [
new CartridgeConnector(
[
Expand Down
14 changes: 8 additions & 6 deletions packages/keychain/src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import {
Formik,
useFormikContext,
} from "formik";
import {
PortalBanner,
PortalFooter,
} from "components";
import { PortalBanner, PortalFooter } from "components";
import { useCallback, useState } from "react";
import Controller from "utils/controller";
import { FormValues, LoginProps } from "./types";
Expand All @@ -19,7 +16,7 @@ import { beginLogin, onLoginFinalize } from "hooks/account";
import { WebauthnSigner } from "utils/webauthn";
import base64url from "base64url";
import { useClearField } from "./hooks";
import { fetchAccount, validateUsernameFor } from "./utils";
import { dropCookie, fetchAccount, validateUsernameFor } from "./utils";
import { RegistrationLink } from "./RegistrationLink";
import { useControllerTheme } from "hooks/theme";

Expand Down Expand Up @@ -50,6 +47,7 @@ export function Login({

try {
log({ type: "webauthn_login", address });
await dropCookie();

const { data: beginLoginData } = await beginLogin(values.username);
const signer = new WebauthnSigner(credentialId, publicKey);
Expand Down Expand Up @@ -124,7 +122,11 @@ function Form({
return (
<FormikForm style={{ width: "100%" }}>
<PortalBanner
title={theme.id === "cartridge" ? "Play with Cartridge Controller" : `Play ${theme.name}`}
title={
theme.id === "cartridge"
? "Play with Cartridge Controller"
: `Play ${theme.name}`
}
description="Enter your Controller username"
/>

Expand Down

0 comments on commit 93f3031

Please sign in to comment.