impr(server): don't return errors for public endpoints when providing authorization

This commit is contained in:
Miodec 2023-09-26 14:44:45 +01:00
parent 89e8fef2b3
commit 923f69ab55
3 changed files with 8 additions and 9 deletions

View file

@ -48,7 +48,7 @@ const requireDailyLeaderboardsEnabled = validateConfiguration({
router.get(
"/",
authenticateRequest({ isPublic: true, acceptApeKeys: true }),
authenticateRequest({ isPublic: true }),
withApeRateLimiter(RateLimit.leaderboardsGet),
validateRequest({
query: LEADERBOARD_VALIDATION_SCHEMA_WITH_LIMIT,

View file

@ -496,7 +496,6 @@ router.get(
requireProfilesEnabled,
authenticateRequest({
isPublic: true,
acceptApeKeys: true,
}),
withApeRateLimiter(RateLimit.userProfileGet),
validateRequest({

View file

@ -45,18 +45,18 @@ function authenticateRequest(authOptions = DEFAULT_OPTIONS): Handler {
const { authorization: authHeader } = req.headers;
try {
if (authHeader) {
token = await authenticateWithAuthHeader(
authHeader,
req.ctx.configuration,
options
);
} else if (options.isPublic) {
if (options.isPublic === true) {
token = {
type: "None",
uid: "",
email: "",
};
} else if (authHeader) {
token = await authenticateWithAuthHeader(
authHeader,
req.ctx.configuration,
options
);
} else if (process.env.MODE === "dev") {
token = authenticateWithBody(req.body);
} else {