laravel-auditing icon indicating copy to clipboard operation
laravel-auditing copied to clipboard

How to store user id where record does not exist in user table

Open shaunthornburgh opened this issue 3 years ago • 2 comments

Q A
Bug? no
New Feature? no
Framework Laravel
Framework version 7.0
Package version 12.0
PHP version 7.4

Actual Behaviour

I have a microservice where the user isn't stored in the database, but the user_id is sent it the request

Expected Behaviour

I would like the user id in the request to be stored in the audit record.

Steps to Reproduce

I have tried implementing my own user resolver however this is expecting to return a user object, and I only have the id.

shaunthornburgh avatar Jun 10 '21 14:06 shaunthornburgh

I also have this question.

My company uses a 3 tiered system for our web application:

Front end - client layer Middle layer (composes requests, provides validation and authentication) - accessible by the front end Backend - where all the database requests are made, not accessible by the front end

In addition we have a SOA architecture which separates parts of our application. For example, the accounts API is completely separate from the Ads API (which is my primary focus). This means that I don't have a User model available to me in the backend API.

Is it possible to explicitly provide a "user_id", retrieved from the request object, instead of relying on some sort of foreign key or implicitly retrieved user id?

The idea would be that a request to retrieve history for an edited record would simply return the provided user_id. We would then merge that with a request against our Accounts API to determine who the actual user was.

We're using Lumen 8.x for middle and back end layers.

commadelimited avatar Sep 27 '21 21:09 commadelimited

UserResolver

erikn69 avatar Nov 19 '21 17:11 erikn69

You can add any custom values with transformAudit https://laravel-auditing.com/guide/audit-transformation.html

parallels999 avatar Mar 08 '23 13:03 parallels999