Skip to content

Commit ae8570e

Browse files
committed
Reset password for a User endpoint added to API generation
1 parent e6df312 commit ae8570e

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

lib/api/users.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,15 +2130,41 @@ module.exports = (db, server, userHandler, settingsHandler) => {
21302130
);
21312131

21322132
server.post(
2133-
'/users/:user/password/reset',
2133+
{
2134+
path: '/users/:user/password/reset',
2135+
summary: 'Reset password for a User',
2136+
description: 'This method generates a new temporary password for a User. Additionally it removes all two-factor authentication settings',
2137+
tags: ['Users'],
2138+
validationObjs: {
2139+
requestBody: {
2140+
validAfter: Joi.date().empty('').allow(false).description('Allow using the generated password not earlier than provided time'),
2141+
sess: sessSchema,
2142+
ip: sessIPSchema
2143+
},
2144+
queryParams: {},
2145+
pathParams: {
2146+
user: userId
2147+
},
2148+
response: {
2149+
200: {
2150+
description: 'Success',
2151+
model: Joi.object({
2152+
success: successRes,
2153+
password: Joi.string().required().description('Temporary password')
2154+
})
2155+
}
2156+
}
2157+
}
2158+
},
21342159
tools.responseWrapper(async (req, res) => {
21352160
res.charSet('utf-8');
21362161

2137-
const schema = Joi.object().keys({
2138-
user: Joi.string().hex().lowercase().length(24).required(),
2139-
validAfter: Joi.date().empty('').allow(false),
2140-
sess: sessSchema,
2141-
ip: sessIPSchema
2162+
const { pathParams, requestBody, queryParams } = req.route.spec.validationObjs;
2163+
2164+
const schema = Joi.object({
2165+
...pathParams,
2166+
...requestBody,
2167+
...queryParams
21422168
});
21432169

21442170
const result = schema.validate(req.params, {

0 commit comments

Comments
 (0)