mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 11:20:15 +01:00
chore: Update people picker access middleware to use PrincipalType constants
This commit is contained in:
parent
4e7379a861
commit
4736a60c47
1 changed files with 3 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
const { PermissionTypes, Permissions } = require('librechat-data-provider');
|
const { PrincipalType, PermissionTypes, Permissions } = require('librechat-data-provider');
|
||||||
const { getRoleByName } = require('~/models/Role');
|
const { getRoleByName } = require('~/models/Role');
|
||||||
const { logger } = require('~/config');
|
const { logger } = require('~/config');
|
||||||
|
|
||||||
|
|
@ -32,14 +32,14 @@ const checkPeoplePickerAccess = async (req, res, next) => {
|
||||||
const canViewUsers = peoplePickerPerms[Permissions.VIEW_USERS] === true;
|
const canViewUsers = peoplePickerPerms[Permissions.VIEW_USERS] === true;
|
||||||
const canViewGroups = peoplePickerPerms[Permissions.VIEW_GROUPS] === true;
|
const canViewGroups = peoplePickerPerms[Permissions.VIEW_GROUPS] === true;
|
||||||
|
|
||||||
if (type === 'user') {
|
if (type === PrincipalType.USER) {
|
||||||
if (!canViewUsers) {
|
if (!canViewUsers) {
|
||||||
return res.status(403).json({
|
return res.status(403).json({
|
||||||
error: 'Forbidden',
|
error: 'Forbidden',
|
||||||
message: 'Insufficient permissions to search for users',
|
message: 'Insufficient permissions to search for users',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (type === 'group') {
|
} else if (type === PrincipalType.GROUP) {
|
||||||
if (!canViewGroups) {
|
if (!canViewGroups) {
|
||||||
return res.status(403).json({
|
return res.status(403).json({
|
||||||
error: 'Forbidden',
|
error: 'Forbidden',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue