Skip to content

Commit

Permalink
block possibility to add new cd if user isnt sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
drillprop committed Feb 25, 2019
1 parent f7749ae commit 94d3ffc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/graphql/resolvers/Mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import 'dotenv/config';

const Mutation = {
createCd: async (parent, args, ctx, info) => {
const user = await User.findById(ctx.req.userId);
if (!user) {
throw new Error('Sign in to add a cd');
}
let { title, artist, image } = args;
const album = new Album({ title, artist, image });
await album.save();
Expand Down

0 comments on commit 94d3ffc

Please sign in to comment.