Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/baseRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,21 @@ const addBaseRoutes = (server, options) => {
method: 'PUT',
path: `/${modelName}/{id?}`,
handler: async (request) => {
const data = Object.keys(request.payload).length > 0 ? request.payload : null;
let data = Object.keys(request.payload).length > 0 ? request.payload : null;
const id = request.params.id ? encodeURIComponent(request.params.id) : null;
const { identityKey, passcodeKey, authModel } = authConfig;
if (authModel === modelName) {
if (request.payload[identityKey] && request.payload[passcodeKey]) {
const password = request.payload[authConfig.passcodeKey];
const hash = await auth.hashPassword(password);
data = {
...data,
[authConfig.passcodeKey]: hash,
};
} else {
return Boom.badData('expected params not found');
}
}
if (data && id) {
try {
const model = sequelize.models[modelName];
Expand Down