39 lines
868 B
JavaScript
Raw Normal View History

2022-03-20 19:50:08 +01:00
'use strict';
const { toPlainObject } = require('lodash/fp');
const { checkBadRequest } = require('../../utils');
module.exports = ({ nexus, strapi }) => {
const { nonNull } = nexus;
return {
type: 'UsersPermissionsLoginPayload',
args: {
currentPassword: nonNull('String'),
password: nonNull('String'),
passwordConfirmation: nonNull('String'),
},
description: 'Change user password. Confirm with the current password.',
async resolve(parent, args, context) {
const { koaContext } = context;
koaContext.request.body = toPlainObject(args);
2022-08-08 23:33:39 +02:00
await strapi.plugin('users-permissions').controller('auth').changePassword(koaContext);
2022-03-20 19:50:08 +01:00
const output = koaContext.body;
checkBadRequest(output);
return {
user: output.user || output,
jwt: output.jwt,
};
},
};
};