fixes bug with first-register route
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -8,7 +8,7 @@
|
|||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Program",
|
"name": "Launch Program",
|
||||||
"program": "${workspaceFolder}/demo/init.js"
|
"program": "${workspaceFolder}/demo/server.js"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = (config, User) => ({
|
|||||||
register: (req, res, next) => {
|
register: (req, res, next) => {
|
||||||
const usernameField = config.user.auth.useAsUsername;
|
const usernameField = config.user.auth.useAsUsername;
|
||||||
|
|
||||||
User.register(new User({ usernameField: req.body[usernameField] }), req.body.password, (err, user) => {
|
User.register(new User({ [usernameField]: req.body[usernameField] }), req.body.password, (err, user) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
const error = new APIError('Authentication error', httpStatus.UNAUTHORIZED);
|
const error = new APIError('Authentication error', httpStatus.UNAUTHORIZED);
|
||||||
return next(error);
|
return next(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user