Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions backend/src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { Request, Response, NextFunction } from "express";
import { prisma } from "../lib/prisma.js";
import logger from "../logger.js";
import { registerUserSchema } from "../validators/user.validator.js";
import {
registerUserSchema,
STELLAR_PUBLIC_KEY_REGEX,
} from "../validators/user.validator.js";
import type { AuthenticatedRequest } from "../types/auth.types.js";
import {
DEFAULT_EVENTS_PAGE_SIZE,
Expand Down Expand Up @@ -103,7 +106,7 @@ export const getUser = async (
if (typeof publicKey !== "string") {
return res.status(400).json({ error: "Invalid publicKey parameter" });
}
if (!/^G[A-Z2-7]{55}$/.test(publicKey)) {
if (!STELLAR_PUBLIC_KEY_REGEX.test(publicKey)) {
return res
.status(400)
.json({ error: "Invalid Stellar public key format" });
Expand Down Expand Up @@ -137,7 +140,7 @@ export const getUserEvents = async (
if (typeof publicKey !== "string") {
return res.status(400).json({ error: "Invalid publicKey parameter" });
}
if (!/^G[A-Z2-7]{55}$/.test(publicKey)) {
if (!STELLAR_PUBLIC_KEY_REGEX.test(publicKey)) {
return res
.status(400)
.json({ error: "Invalid Stellar public key format" });
Expand Down Expand Up @@ -251,7 +254,7 @@ export const exportTransactions = async (
? addressParam[0]
: addressParam;

if (!address || !/^G[A-Z2-7]{55}$/.test(address)) {
if (!address || !STELLAR_PUBLIC_KEY_REGEX.test(address)) {
return res.status(400).json({ error: "Invalid Stellar address" });
}

Expand Down
Loading