@joystick.js/node-canary 0.0.0-canary.78 → 0.0.0-canary.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -90,11 +90,15 @@ const signup = async (options, { resolve, reject }) => {
90
90
  return reject("Password is required.");
91
91
  }
92
92
  const existingUser = await getExistingUser(options.emailAddress, options.metadata?.username);
93
- if (existingUser) {
93
+ if (existingUser && process.env.NODE_ENV !== "test") {
94
94
  throw new Error(`A user with the ${existingUser.existingUsername ? "username" : "email address"} ${existingUser.existingUsername || existingUser.existingEmailAddress} already exists.`);
95
95
  }
96
- const userToCreate = await getUserToCreate(options);
97
- const userId = await insertUserInDatabase(userToCreate);
96
+ let userToCreate;
97
+ let userId = existingUser?._id || existingUser?.user_id;
98
+ if (!existingUser) {
99
+ userToCreate = await getUserToCreate(options);
100
+ userId = await insertUserInDatabase(userToCreate);
101
+ }
98
102
  const user = await getUserByUserId(userId);
99
103
  const session = generateSession();
100
104
  if (user?._id || user?.user_id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
- "version": "0.0.0-canary.78",
3
+ "version": "0.0.0-canary.79",
4
4
  "type": "module",
5
5
  "description": "A Node.js framework for building web apps.",
6
6
  "main": "./dist/index.js",