updated temp user control access and limited data send for temps
This commit is contained in:
@@ -44,6 +44,44 @@ class LocationsController {
|
||||
|
||||
logger.info(`Retrieved ${validLocations.length} valid locations out of ${locations.length} total`);
|
||||
|
||||
// Check if user is temp user and limit data accordingly
|
||||
if (req.session?.userType === 'temp') {
|
||||
// For temp users, return limited data but include necessary fields for functionality
|
||||
const limitedLocations = validLocations.map(loc => {
|
||||
const locationId = loc.id || loc.Id || loc.ID || loc._id;
|
||||
return {
|
||||
// Include ID with all possible variants for compatibility
|
||||
id: locationId,
|
||||
Id: locationId,
|
||||
ID: locationId,
|
||||
_id: locationId,
|
||||
'Geo-Location': loc['Geo-Location'],
|
||||
latitude: loc.latitude,
|
||||
longitude: loc.longitude,
|
||||
// Include display fields needed for map functionality
|
||||
'First Name': loc['First Name'] || '',
|
||||
'Last Name': loc['Last Name'] || '', // Include last name for display
|
||||
'Support Level': loc['Support Level'],
|
||||
Address: loc.Address || '',
|
||||
'Unit Number': loc['Unit Number'] || '',
|
||||
Notes: loc.Notes || '',
|
||||
Sign: loc.Sign,
|
||||
'Sign Size': loc['Sign Size'] || '',
|
||||
// Exclude sensitive fields like Email, Phone
|
||||
};
|
||||
});
|
||||
|
||||
logger.info(`Returning limited data for temp user: ${limitedLocations.length} locations`);
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
count: limitedLocations.length,
|
||||
total: response.pageInfo?.totalRows || limitedLocations.length,
|
||||
locations: limitedLocations,
|
||||
isLimited: true // Flag to indicate limited data
|
||||
});
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
count: validLocations.length,
|
||||
|
||||
Reference in New Issue
Block a user