Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
🐛 Fix bug with email authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed May 30, 2019
1 parent ddcba1b commit ec166c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controllers/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class OrganizationController {
);
}

@Get(":id/plans")
@Get(":id/pricing/:product")
async getPlans(req: Request, res: Response) {
const product = req.params.product;
const organizationId = req.params.id;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Joi from "@hapi/joi";
*/
export const safeError = (error: string) => {
const errorString = error.toString();
console.log("Got", errorString);
if (errorString.startsWith("joi:")) {
const joiError = JSON.parse(
errorString.split("joi:")[1]
Expand All @@ -28,5 +27,6 @@ export const sendError = (error: string) => {
const code = error.split("/")[1];
return { status, code } as HTTPError;
}
console.log("Backup error", error);
return { status: 500, code: error } as HTTPError;
};
4 changes: 2 additions & 2 deletions src/rest/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const addEmailToUserForUser = async (
email: string,
locals: Locals
) => {
if (await can(tokenUserId, Authorizations.UPDATE, "user", userId))
if (!(await can(tokenUserId, Authorizations.UPDATE, "user", userId)))
throw new Error(ErrorCode.INSUFFICIENT_PERMISSION);
validate(email, ValidationTypes.EMAIL);
await checkIfNewEmail(email);
Expand All @@ -73,7 +73,7 @@ export const deleteEmailFromUserForUser = async (
emailId: number,
locals: Locals
) => {
if (await can(tokenUserId, Authorizations.UPDATE, "user", userId))
if (!(await can(tokenUserId, Authorizations.UPDATE, "user", userId)))
throw new Error(ErrorCode.INSUFFICIENT_PERMISSION);
const email = await getEmail(emailId);
if (email.userId != userId)
Expand Down

0 comments on commit ec166c5

Please sign in to comment.