How to use the @accounts/server.findUserByEmail function in @accounts/server

To help you get started, we’ve selected a few @accounts/server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RocketChat / Rocket.Chat.PWA / mock-server / oauth / oauth-service.ts View on Github external
userResolver: async (userData) => {
        let user = await findUserByOAuthId('google', userData.id);
        if (user) {
          user.id = user._id;
        }
        else {
          user = await AccountsServer.findUserByEmail(userData.emails[0].value);
        }

        if (user) {
          await addOAuthIdToUserProfile(user, 'google', userData.id);
        }
        else {
          const id = await AccountsServer.createUser({
            username: userData.emails[0].value,
            email: userData.emails[0].value,
            profile: {
              name: userData.name.givenName + ' ' + userData.name.familyName,
              avatar: userData.image.url,
              oauth: {
                google: userData.id,
              }
            }