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