mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 09:56:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			507 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			507 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const createAuthenticatedUser = async ({ strapi, userInfo }) => {
 | |
|   const defaultRole = await strapi.db
 | |
|     .query('plugin::users-permissions.role')
 | |
|     .findOne({ where: { type: 'authenticated' } });
 | |
| 
 | |
|   const user = await strapi.service('plugin::users-permissions.user').add({
 | |
|     role: defaultRole.id,
 | |
|     ...userInfo,
 | |
|   });
 | |
| 
 | |
|   const jwt = strapi.service('plugin::users-permissions.jwt').issue({ id: user.id });
 | |
| 
 | |
|   return { user, jwt };
 | |
| };
 | |
| 
 | |
| module.exports = {
 | |
|   createAuthenticatedUser,
 | |
| };
 | 
