mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 11:54:10 +00:00 
			
		
		
		
	use constant
This commit is contained in:
		
							parent
							
								
									0b057257fd
								
							
						
					
					
						commit
						d78ec0243d
					
				@ -2,6 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const crypto = require('crypto');
 | 
					const crypto = require('crypto');
 | 
				
			||||||
const { map, omit, differenceBy } = require('lodash/fp');
 | 
					const { map, omit, differenceBy } = require('lodash/fp');
 | 
				
			||||||
 | 
					const constants = require('../services/constants');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @typedef {'read-only'|'full-access'|'custom'} TokenType
 | 
					 * @typedef {'read-only'|'full-access'|'custom'} TokenType
 | 
				
			||||||
@ -98,7 +99,7 @@ const create = async attributes => {
 | 
				
			|||||||
  const result = { ...apiToken, accessKey };
 | 
					  const result = { ...apiToken, accessKey };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // If this is a custom type token, create and link the associated permissions
 | 
					  // If this is a custom type token, create and link the associated permissions
 | 
				
			||||||
  if (attributes.type === 'custom') {
 | 
					  if (attributes.type === constants.API_TOKEN_TYPE.CUSTOM) {
 | 
				
			||||||
    const permissions = await strapi
 | 
					    const permissions = await strapi
 | 
				
			||||||
      .query('admin::token-permission')
 | 
					      .query('admin::token-permission')
 | 
				
			||||||
      .createMany({ data: attributes.permissions.map(action => ({ action, token: apiToken.id })) });
 | 
					      .createMany({ data: attributes.permissions.map(action => ({ action, token: apiToken.id })) });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user