Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const resolvers: Resolvers = {
- Mutation: {
- EmailSignUp: async (
- _,
- args: EmailSignUpMutationArgs
- ): Promise<EmailSignUpResponse> => {
- try {
- const { email } = args;
- const existingUser = await User.findOne({ email });
- if (existingUser) {
- return {
- ok: false,
- error: "You should Log in Instead",
- token: null
- };
- } else {
- const phoneVerification = await Verification.findOne({
- payload: args.phoneNumber,
- verified: true
- });
- if (phoneVerification) {
- args.password = await encryptToHash(args.password);
- const newUser = await User.create({ ...args }).save();
- ...
Add Comment
Please, Sign In to add comment