mirror of
https://github.com/strapi/strapi.git
synced 2025-12-08 21:39:46 +00:00
Add didCompleteRequest event
This commit is contained in:
parent
943f6178de
commit
0740be570f
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { castArray, isNil } = require('lodash/fp');
|
const { castArray, isNil, isEmpty } = require('lodash/fp');
|
||||||
const { UnauthorizedError, ForbiddenError } = require('@strapi/utils').errors;
|
const { UnauthorizedError, ForbiddenError } = require('@strapi/utils').errors;
|
||||||
const constants = require('../services/constants');
|
const constants = require('../services/constants');
|
||||||
const { getService } = require('../utils');
|
const { getService } = require('../utils');
|
||||||
@ -78,6 +78,13 @@ const authenticate = async (ctx) => {
|
|||||||
const verify = (auth, config) => {
|
const verify = (auth, config) => {
|
||||||
const { credentials: apiToken, ability } = auth;
|
const { credentials: apiToken, ability } = auth;
|
||||||
|
|
||||||
|
strapi.telemetry.send('didCompleteRequest', {
|
||||||
|
eventProperties: {
|
||||||
|
authenticationMetod: auth?.strategy?.name || 'api-token',
|
||||||
|
isAuthenticated: !isEmpty(apiToken),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!apiToken) {
|
if (!apiToken) {
|
||||||
throw new UnauthorizedError('Token not found');
|
throw new UnauthorizedError('Token not found');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { castArray, map, every, pipe } = require('lodash/fp');
|
const { castArray, map, every, pipe, isEmpty } = require('lodash/fp');
|
||||||
const { ForbiddenError, UnauthorizedError } = require('@strapi/utils').errors;
|
const { ForbiddenError, UnauthorizedError } = require('@strapi/utils').errors;
|
||||||
|
|
||||||
const { getService } = require('../utils');
|
const { getService } = require('../utils');
|
||||||
@ -80,6 +80,13 @@ const authenticate = async (ctx) => {
|
|||||||
const verify = async (auth, config) => {
|
const verify = async (auth, config) => {
|
||||||
const { credentials: user, ability } = auth;
|
const { credentials: user, ability } = auth;
|
||||||
|
|
||||||
|
strapi.telemetry.send('didCompleteRequest', {
|
||||||
|
eventProperties: {
|
||||||
|
authenticationMetod: auth?.strategy?.name,
|
||||||
|
isAuthenticated: !isEmpty(auth.credentials),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!config.scope) {
|
if (!config.scope) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
// A non authenticated user cannot access routes that do not have a scope
|
// A non authenticated user cannot access routes that do not have a scope
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user