mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 09:56:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			39 lines
		
	
	
		
			868 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			868 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| '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);
 | |
| 
 | |
|       await strapi.plugin('users-permissions').controller('auth').changePassword(koaContext);
 | |
| 
 | |
|       const output = koaContext.body;
 | |
| 
 | |
|       checkBadRequest(output);
 | |
| 
 | |
|       return {
 | |
|         user: output.user || output,
 | |
|         jwt: output.jwt,
 | |
|       };
 | |
|     },
 | |
|   };
 | |
| };
 | 
