Skip to content

Commit

Permalink
fix auth again
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Oct 1, 2024
1 parent c3c43aa commit ee7dc00
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ app.use((err: unknown, req: Request, res: Response, next: NextFunction) => {
if (!err) return next();

// logs and handles errors
const apiError = handleError(err, req.path);
const apiError = handleError(err, req.path, req.method);
if (err instanceof ValidateError) {
res
.status(422)
Expand Down
2 changes: 1 addition & 1 deletion src/v2/tools/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function expressAuthentication(
}

// check add-on ownership
if (scopes.includes("addon:own")) {
if (scopes.includes("addon:own") || scopes.includes("addon:approved")) {
const idOrSlug = request.params.id_or_slug;
if (isSlug(idOrSlug)) {
const addon: Addon = (await addonService.getAddonFromSlugOrId(idOrSlug))[1];
Expand Down
4 changes: 2 additions & 2 deletions src/v2/tools/handleError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { APIError } from "./errors";
* @param err error to handle
* @returns front-end API error to show user
*/
export default function handleError(err: any, route: string): APIError {
export default function handleError(err: any, route: string, method: string): APIError {
const code =
Number(
(typeof err.status === "number" ? err.status : err.statusCode) ||
Expand All @@ -21,7 +21,7 @@ export default function handleError(err: any, route: string): APIError {

let printed = false;
if (process.env.VERBOSE === "true") {
console.error(`[${new Date().toUTCString()}] ${route}`);
console.error(`[${new Date().toUTCString()}] ${method} ${route}`);
// if the message already includes a stack don't print it twice
if (message?.stack) console.error(`(${code})`, message);
else console.error(`(${code})`, message, "\n", stack);
Expand Down

0 comments on commit ee7dc00

Please sign in to comment.