Fix: ManageUsers component missing useAuth() - caused blank admin page

The ManageUsers sub-component referenced user?.role for conditional
role dropdown options but didn't call useAuth() to get the user object.
This caused 'user is not defined' JS errors and blank admin pages.

Browser E2E: 20/20 tests pass.
This commit is contained in:
BizzleBot
2026-02-16 20:24:34 +00:00
parent f718a76153
commit 70ed672381
11 changed files with 231 additions and 72 deletions
+1
View File
@@ -9,6 +9,7 @@ datasource db {
enum Role {
employee
office
admin
super_admin
}
+140 -45
View File
@@ -4,52 +4,147 @@ const bcrypt = require('bcryptjs');
const prisma = new PrismaClient();
const DEFAULT_HOMEOWNERS = [
'Anderson, 217',
'Bakos',
'Beckstead, 111',
'Bentley, 310',
'Best, 103',
'Caraway, 132',
'Carmichael, M, 216',
'Casa Blanca',
'Chapin, 106',
'Conner, 309',
'Cook, 118',
'Coyle, 109',
'Davis, 114a',
'Dimmitt, 213',
'Dockery, 502',
'Fassett, 303C',
'Gypsy Wind',
'Hager, 108',
'Hanford, 308',
'Hitchcox – Clarry, 218',
'Hughes, 215',
'Kaufman 129 (Blue View)',
'Kuchman, 104',
'Lockhart, 301A',
'Lokey, 136',
'McColgan, 312',
'Mercurio, 523',
'Moff – Dean Elect',
'Rogers, 501',
'Rusten, 204A',
'Ryan, 301B',
'Salas, 144',
'Sear 128 (Twin Shores)',
'Shimp, 517',
'Sipprelle, 202',
'Trino, 131',
'Useppa Fire',
'Vogt',
'Weinsz, 141',
'Wendorf, 306',
'White (Rogan)',
'Williams, Bob, 140',
'Freeman, 101',
'Williamson (Clam Shell Cottage), 102',
'Best, Steve (Hog Heaven), 103',
'Kuchman, Jeff & Cindy (Easter Cottage), 104',
'Parsons, David & Donna (Ibis Cottage), 105A',
'Carroll / Young (Egret Cottage), 105B',
'Chapin, Kay & Charlie (Morning Glory), 106',
'Young (Sanibel Cottage), 107',
'Hager A (Banyan Cottage), 108',
'Coyle (Cayo Costa), 109',
'Bound, Simon (Mondongo), 110',
'Beckstead (A Gasparilla, B Sunset I), 111AB',
'Symonds (Captiva Cottage), 112',
'Kerr (Shell Cottage), 113',
'Davis, Beth (White Sands Cottage), 114A',
'UIDC (Turtle Grass Cottage), 114B',
'Fletemeyer, John, 115',
'Kimberg (Cottage 16 North), 116A',
'Corey (Bamboo Cottage), 116B',
'Wilson, Clyde (High Tide), 117',
'Cook, Randy & Beata (Cottage 18), 118',
'Miller (Folly Cottage), 119',
'Miller (Honeymoon Cottage), 120',
'Miller (Conch Out Cottage), 121',
'Miller - gazebo, 122',
'Simpson (North Point Cottage), 123A',
'Amsler, Virginia (Ginny) (Whelk Cottage), 123B',
'Prosser (Sea Mystic), 124',
'Strickland, Bonnie, 125',
'Beisswenger/ Kruzi, 126',
'Albert, Michael (Cottage 27), 127',
'Sear (Twin Shore), 128',
'Kaufman, Steve (Blue View), 129',
'Fetter, Tim & Megan, 130A',
'Ullrich, David & Anja, 130B',
'Trino, Vic & Suzy, 131',
'Caraway, Jim (Dolphin Cottage), 132',
'Escobar, Rick (Little Mermaid), 133',
'Vance, Paul (Serne Mermaid), 134',
'Lokey (lot), 135',
'Lokey, Phil & Shannon, 136',
'Wright, Clark (Fish Hawk), 137A',
'Williams, Dan, 137B',
'Williamson-Whetstone, 102',
'Wilson, George, 516',
'Wright, 137A',
'Preckwinkle, George, 138A',
'Preckwinkle, George (Calusa South), 138B',
'Collier - lot, 139',
'Williams, Bob, 140',
'Weinsz, Steve, 141',
'Lawler, Michael (Sea level), 142A',
'Lawler (Sea Level Cottage), 142B',
'Ketay, 143',
'Salas, Joe (West Wind), 144',
'Buchanan (Eagles Nest), 145',
'Buchanan (Eagles Nest), 146',
'Nutting - lot, 147',
'Firehouse, 200',
'Smith, Sawyer (Alibi Cottage), 201',
'Sipprelle, Dwight (The Aerie), 202',
'Sipprelle -lot, 203',
'Rusten, Brendt (Take Five), 204A',
'Useppa One LLC (Rusten), 204B',
'Useppa One LLC (Rusten)- gazebo, 205',
'Mezyninski, Steve (Hill Tide), 206',
'Sullivan, 207',
'Sullivan, 208',
'Nutting (A Little Piece of Heaven), 209',
'UIDC - Donald (Live Oak Cottage), 210',
'Newbold, Carol (Palm Cottage), 211',
'Dimmitt, Peter (Lookout Cottage), 212',
'Dimmitt, Peter (Lookout Cottage), 213',
'Greenwell (Hide-A-Way Cottage), 214',
'Hughes, Dave (Cottage 15), 215',
'Carmichael, Michael (8 Palms), 216',
'Anderson, Donna (Island Time), 217',
'Hitchcox, Doug, 218',
'Lockhart, Kim (Coquina Cottage), 301A',
'Ryan, Doug & Cindy, 301B',
'Duke - lot, 302',
'Stuart, Deb, 303A',
'Judge, James (Osprey Point), 303B',
'Fassett, Ladd (Cottage 3AN), 303C',
'Ink (Cottage 3AS), 303D',
'McGinn (Gaspar Island), 304',
'McGinn (Gaspar Island), 305',
'Wendorf, Bruce & Hillary (It\'s a Wendorful Life Cottage), 306',
'Bennett, 307',
'Hanford, Ken & Kim, 308',
'Conner, Drew & Paige (Campfire Lighter), 309',
'Bentley, Joel & Sue, 310',
'Covington/Bernard, 311A',
'O\'Connell (Often Inn), 311B',
'McColgan, Brian (La Costa Sunset), 312',
'Preckwinkle, George, 313',
'Perrone (Lagoona Vista), 314',
'Thompson, Jim, 315',
'Nutting - lot, 316',
'Nutting - lot, 317',
'Kent / Williamson (Kaos Kattage), 318',
'Kahane -lot, 319',
'Kahane (Belvedere Cottage?), 320',
'Nutting - lot, 321',
'Molosky, Andrew, 322A',
'Folkerth, Betty (Living Water Cottage), 322B',
'Rowars, Chuck (Mangoes), 323',
'Eldemir, Alex, 324',
'Paradise Partnership, 325',
'Ricciardelli - lot, 326',
'Cardwell - lot, 327',
'Spencer, Doug & Holly, 328',
'Walker, Jeff & Alicia (HighSeas), 329',
'Loeks - lot, 401',
'Loeks - lot, 402',
'Loeks - lot, 403',
'Wilson, George - lot, 404',
'Nutting - lot, 405',
'Nutting - lot, 406',
'Soriero - lot, 407',
'Alderman, Gary, 501',
'Dockery, Bob & Susan, 502',
'Hansen (Starfish Cottage), 503',
'Berger / Bevis (Castaway), 504',
'Tinney, John, 505',
'Matter, John, 506',
'Stuart (Fancy Free), 507',
'Fernandez, 508',
'Wiesen, Matt & Katy, 509',
'Romine, Dave, 510',
'Handin (Grandview Cottage), 511',
'Colgan, Tony (Cottage 12), 512',
'Cupello (White Rose Cottage), 513',
'Meyer (Burgee Cottage), 514',
'Jarvis, Jim & Patty (Laguna Cottage), 515',
'Wilson, George (Cottage 16), 516',
'Shimp, Kevin, 517',
'Dreher, Brucke (Island Escape), 518',
'Beckman (Mangrove Cottage), 519',
'Gatewood (Water Wings), 520',
'Duke, Steve & Janie (Dutchess Cottage), 521',
'Useppa Island LLC, 522',
'Mercurio, Michael & Beth (Osprey Nest), 523',
'Compton, Janie (Dvorak), 524',
];
async function main() {
+1 -1
View File
@@ -72,7 +72,7 @@ function authenticate(req, res, next) {
* Admin-only middleware — must be called after authenticate
*/
function requireAdmin(req, res, next) {
if (!req.user || (req.user.role !== 'admin' && req.user.role !== 'super_admin')) {
if (!req.user || !['office', 'admin', 'super_admin'].includes(req.user.role)) {
return res.status(403).json({ error: 'Admin access required' });
}
next();
+1 -1
View File
@@ -14,7 +14,7 @@ const registerSchema = z.object({
.min(8, 'Password must be at least 8 characters')
.max(128),
name: z.string().min(1, 'Name is required').max(100).trim(),
role: z.enum(['employee', 'admin', 'super_admin']).default('employee'),
role: z.enum(['employee', 'office', 'admin', 'super_admin']).default('employee'),
});
const refreshSchema = z.object({