mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-09 15:15:58 +08:00
impr(server): don't return errors for public endpoints when providing authorization
This commit is contained in:
parent
89e8fef2b3
commit
923f69ab55
3 changed files with 8 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -496,7 +496,6 @@ router.get(
|
|||
requireProfilesEnabled,
|
||||
authenticateRequest({
|
||||
isPublic: true,
|
||||
acceptApeKeys: true,
|
||||
}),
|
||||
withApeRateLimiter(RateLimit.userProfileGet),
|
||||
validateRequest({
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue