Skip to content
Snippets Groups Projects
Commit 3dbfa9cd authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

feat(component-user-manager): add change password

parent 1d1143b2
No related branches found
No related tags found
1 merge request!14Sprint #15
......@@ -81,11 +81,17 @@ const users = {
lastName: user.lastName,
affiliation: chance.company(),
title: 'Mr',
save: jest.fn(() => users.user),
save: jest.fn(function save() {
return this
}),
isConfirmed: false,
updateProperties: jest.fn(() => users.user),
teams: [],
confirmationToken: chance.hash(),
validPassword: jest.fn(function validPassword(password) {
return this.password === password
}),
token: chance.hash(),
},
author: {
type: 'user',
......
......@@ -2,6 +2,9 @@ const bodyParser = require('body-parser')
const Invite = app => {
app.use(bodyParser.json())
const authBearer = app.locals.passport.authenticate('bearer', {
session: false,
})
/**
* @api {post} /api/users/reset-password Reset password
* @apiGroup Users
......@@ -88,6 +91,38 @@ const Invite = app => {
'/api/users/forgot-password',
require('./routes/users/forgotPassword')(app.locals.models),
)
/**
* @api {post} /api/users/change-password Change password
* @apiGroup Users
* @apiParamExample {json} Body
* {
* "password": "currentPassword",
* "newPassword": "newPassword",
* }
* @apiSuccessExample {json} Success
* HTTP/1.1 200 OK
* {
* "id": "a6184463-b17a-42f8-b02b-ae1d755cdc6b",
* "type": "user",
* "admin": false,
* "email": "email@example.com",
* "teams": [],
* "username": "email@example.com",
* "fragments": [],
* "collections": [],
* "isConfirmed": true,
* "editorInChief": false,
* "handlingEditor": false
* }
* @apiErrorExample {json} Reset password errors
* HTTP/1.1 400 Bad Request
* HTTP/1.1 404 Not Found
*/
app.post(
'/api/users/change-password',
authBearer,
require('./routes/users/changePassword')(app.locals.models),
)
}
module.exports = Invite
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment