mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-15 02:50:10 +01:00
bugfix: API new user return 400 if user creation failed (#1898)
* return 400 if user creation failed The client might not check the error field unless they realize it's a 4xx error instead of 200 success. * Update index.js * use one-liner style --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
parent
5df6b5f7d9
commit
c4158b97d6
@ -133,7 +133,7 @@ function apiAdminEndpoints(app) {
|
||||
|
||||
const newUserParams = reqBody(request);
|
||||
const { user: newUser, error } = await User.create(newUserParams);
|
||||
response.status(200).json({ user: newUser, error });
|
||||
response.status(newUser ? 200 : 400).json({ user: newUser, error });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
response.sendStatus(500).end();
|
||||
|
Loading…
Reference in New Issue
Block a user