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",
|
||||
"request": "launch",
|
||||
"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) => {
|
||||
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) {
|
||||
const error = new APIError('Authentication error', httpStatus.UNAUTHORIZED);
|
||||
return next(error);
|
||||
|
||||
Reference in New Issue
Block a user