mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 09:00:19 +00:00
42 lines
901 B
JavaScript
42 lines
901 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
const { toPlainObject } = require('lodash/fp');
|
||
|
|
||
|
const { checkBadRequest } = require('../../utils');
|
||
|
|
||
|
module.exports = ({ nexus, strapi }) => {
|
||
|
const { nonNull } = nexus;
|
||
|
|
||
|
return {
|
||
|
type: 'UsersPermissionsLoginPayload',
|
||
|
|
||
|
args: {
|
||
|
password: nonNull('String'),
|
||
|
passwordConfirmation: nonNull('String'),
|
||
|
code: nonNull('String'),
|
||
|
},
|
||
|
|
||
|
description: 'Reset user password. Confirm with a code (resetToken from forgotPassword)',
|
||
|
|
||
|
async resolve(parent, args, context) {
|
||
|
const { koaContext } = context;
|
||
|
|
||
|
koaContext.request.body = toPlainObject(args);
|
||
|
|
||
|
await strapi
|
||
|
.plugin('users-permissions')
|
||
|
.controller('auth')
|
||
|
.forgotPassword(koaContext);
|
||
|
|
||
|
const output = koaContext.body;
|
||
|
|
||
|
checkBadRequest(output);
|
||
|
|
||
|
return {
|
||
|
user: output.user || output,
|
||
|
jwt: output.jwt,
|
||
|
};
|
||
|
},
|
||
|
};
|
||
|
};
|