Skip to content

Commit

Permalink
fix: graphQL logout
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Jan 2, 2021
1 parent cd9b360 commit 709cc9c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/auth/operations/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ export type Arguments = {
async function logout(args: Arguments): Promise<string> {
const { config } = this;

const requestedSlug = args.req.route.path.split('/').filter((r) => r !== '')[0];
if (!args.req.user) throw new APIError('No User', httpStatus.BAD_REQUEST);
if (args.req.user.collection !== requestedSlug) throw new APIError('Incorrect collection', httpStatus.FORBIDDEN);

const {
res,
collection: {
config: collectionConfig,
},
} = args;

if (!args.req.user) throw new APIError('No User', httpStatus.BAD_REQUEST);
if (args.req.user.collection !== collectionConfig.slug) throw new APIError('Incorrect collection', httpStatus.FORBIDDEN);

const cookieOptions = {
path: '/',
httpOnly: true,
Expand Down

0 comments on commit 709cc9c

Please sign in to comment.