Skip to content

Commit 53b7b2a

Browse files
fix(functions): fix-address-fetching-from-jwt-payload
1 parent e985455 commit 53b7b2a

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

web/netlify/functions/fetch-settings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { authMiddleware } from "../middleware/authMiddleware";
66

77
const fetchSettings = async (event) => {
88
try {
9-
const address = event.auth.id;
9+
const address = event.auth.sub;
1010
const lowerCaseAddress = address.toLowerCase() as `0x${string}`;
1111

1212
const supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_CLIENT_API_KEY!);

web/netlify/functions/update-settings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const updateSettings = async (event) => {
6363
const lowerCaseAddress = address.toLowerCase() as `0x${string}`;
6464

6565
// Prevent using someone else's token
66-
if (event?.auth?.id.toLowerCase() !== lowerCaseAddress) {
66+
if (event?.auth?.sub.toLowerCase() !== lowerCaseAddress) {
6767
throw new Error("Unauthorised user");
6868
}
6969
const supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_CLIENT_API_KEY!);

web/netlify/middleware/authMiddleware.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export const authMiddleware = () => {
1414
}
1515

1616
try {
17-
// const secret = process.env.JWT_SECRET;
18-
// TODO testing purpose
19-
const secret = "u03tzA7Un9w+fetret343t6U2YaOlINle1E4avjc=";
17+
const secret = process.env.JWT_SECRET;
2018

2119
if (!secret) {
2220
throw new Error("Secret not set in environment");

0 commit comments

Comments
 (0)