How to use the @accounts/server.ServerHooks.CreateUserError 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 accounts-js / accounts / packages / oauth / src / accounts-oauth.ts View on Github external
}

    if (!user) {
      try {
        const userId = await this.db.createUser({
          email: oauthUser.email,
        });

        user = (await this.db.findUserById(userId)) as User;

        if (this.server) {
          await this.server.getHooks().emit(ServerHooks.CreateUserSuccess, user);
        }
      } catch (e) {
        if (this.server) {
          await this.server.getHooks().emit(ServerHooks.CreateUserError, user);
        }

        throw e;
      }
    }

    await this.db.setService(user.id, params.provider, oauthUser);

    return user;
  }
github accounts-js / accounts / packages / password / src / accounts-password.ts View on Github external
]);

    try {
      const userId = await this.db.createUser(user);

      defer(async () => {
        if (this.options.sendVerificationEmailAfterSignup && user.email)
          this.sendVerificationEmail(user.email);

        const userRecord = (await this.db.findUserById(userId)) as User;
        this.server.getHooks().emit(ServerHooks.CreateUserSuccess, userRecord);
      });

      return userId;
    } catch (e) {
      await this.server.getHooks().emit(ServerHooks.CreateUserError, user);
      throw e;
    }
  }