Skip to content

Commit 6658da7

Browse files
committed
feat: removed commented code
1 parent 9ab7762 commit 6658da7

File tree

2 files changed

+3
-87
lines changed

2 files changed

+3
-87
lines changed

src/components/Topbar.tsx

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,7 @@ import {
2424
import NextLink from "next/link";
2525
import SchoolOfCodeLogo from "./SchoolOfCodeLogo";
2626
import { useRouter } from "next/router";
27-
// import { getCsrfToken, signIn, signOut, useSession } from "next-auth/react";
28-
// import { api } from '@/utils/api'
29-
// SIWE Integration
30-
// import { SiweMessage } from "siwe";
31-
// import {
32-
// useAccount,
33-
// useConnect,
34-
// useDisconnect,
35-
// useSignMessage,
36-
// useNetwork,
37-
// } from "wagmi";
38-
// import { InjectedConnector } from "wagmi/connectors/injected";
39-
// import { useEffect, useState } from "react";
27+
4028
import { ConnectButton } from "@rainbow-me/rainbowkit";
4129

4230
interface NavItem {
@@ -65,69 +53,6 @@ export default function Topbar() {
6553
const { isOpen, onToggle } = useDisclosure();
6654
const router = useRouter();
6755

68-
// Hooks
69-
// const { data: sessionData } = useSession();
70-
// const { data: secretMessage } = api.example.getSecretMessage.useQuery(
71-
// undefined, // no input
72-
// { enabled: sessionData?.user !== undefined }
73-
// );
74-
// State
75-
// const [showConnection, setShowConnection] = useState(false);
76-
77-
// Wagmi Hooks
78-
// const { signMessageAsync } = useSignMessage();
79-
// const { address, isConnected } = useAccount();
80-
// const { connect } = useConnect({
81-
// connector: new InjectedConnector(),
82-
// });
83-
// const { disconnect } = useDisconnect();
84-
// const { chain } = useNetwork();
85-
86-
// Functions
87-
/**
88-
* Attempts SIWE and establish session
89-
*/
90-
// const onClickSignIn = async () => {
91-
// try {
92-
// const message = new SiweMessage({
93-
// domain: window.location.host,
94-
// address: address,
95-
// statement: "Sign in with Ethereum to the app.",
96-
// uri: window.location.origin,
97-
// version: "1",
98-
// chainId: chain?.id,
99-
// // nonce is used from CSRF token
100-
// nonce: await getCsrfToken(),
101-
// });
102-
// const signature = await signMessageAsync({
103-
// message: message.prepareMessage(),
104-
// });
105-
// await signIn("credentials", {
106-
// message: JSON.stringify(message),
107-
// redirect: false,
108-
// signature,
109-
// });
110-
// } catch (error) {
111-
// window.alert(error);
112-
// }
113-
// };
114-
115-
/**
116-
* Sign user out
117-
*/
118-
// const onClickSignOut = async () => {
119-
// await signOut();
120-
// };
121-
122-
// Hooks
123-
/**
124-
* Handles hydration issue
125-
* only show after the window has finished loading
126-
*/
127-
// useEffect(() => {
128-
// setShowConnection(true);
129-
// }, []);
130-
13156
return (
13257
<Box
13358
as="header"

src/server/auth.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,31 +169,24 @@ export const authOptions: (ctxReq: CtxOrReq) => NextAuthOptions = ({
169169
const nonce = await getCsrfToken({ req: { headers: req?.headers } });
170170
// const nonce = await getCsrfToken({ req });
171171

172-
// const nextAuthUrl = new URL(env.NEXTAUTH_URL);
173-
174172
const verified = await siwe.verify({
175173
signature: credentials?.signature || "",
176-
// domain: nextAuthUrl.host,
177174
nonce,
178175
});
179-
console.log({ verified });
180176

181177
if (!verified.success) {
182178
throw new Error("Verification failed");
183179
}
184180

185181
const { data: fields } = verified;
186182

187-
console.log({ fields });
188-
189183
// Check if user exists
190184
let user = await prisma.user.findUnique({
191185
where: {
192186
address: fields.address,
193187
},
194188
});
195189

196-
console.log("1 ", { user });
197190
// Create new user if doesn't exist
198191
if (!user) {
199192
user = await prisma.user.create({
@@ -203,17 +196,15 @@ export const authOptions: (ctxReq: CtxOrReq) => NextAuthOptions = ({
203196
},
204197
});
205198

206-
console.log("2 ", { user });
207-
// create account
208-
const newAccount = await prisma.account.create({
199+
// if new then create account
200+
await prisma.account.create({
209201
data: {
210202
userId: user.id,
211203
type: "credentials",
212204
provider: "Ethereum",
213205
providerAccountId: fields.address,
214206
},
215207
});
216-
console.log({ newAccount });
217208
}
218209

219210
return {

0 commit comments

Comments
 (0)