### What? When read access is restricted on the `users` collection - restricted users would not have access to other users complete user data object only their IDs when accessing `user.value`. ### Why? This is problematic when determining the lock status of a document from a restricted users perspective as `user.id` would not exist - the user data would not be an object in this case but instead a `string` or `number` value for user ID ### How? This PR properly handles both cases now and checks if the incoming user data is an object or just a `string` / `number`.
6 lines
153 B
TypeScript
6 lines
153 B
TypeScript
import type { ClientUser } from 'payload'
|
|
|
|
export const isClientUserObject = (user): user is ClientUser => {
|
|
return user && typeof user === 'object'
|
|
}
|