File: backend/src/utils/database.ts
- ✅ Added
collegestable - ✅ Updated
userstable with new fields:- username, prn, batch, department, college_id
- year_of_study, bio, avatar_url
- verified, linkedin_id, approval_status
File: backend/src/utils/prnValidation.ts
- ✅ Format validation (6-20 alphanumeric)
- ✅ Duplicate check
- ✅ Auto uppercase conversion
File: backend/src/config/passport.ts
- ✅ Passport LinkedIn strategy
- ✅ Auto-fetch college from LinkedIn education
- ✅ Auto college record creation
File: backend/src/controllers/authController.ts
- ✅ Enhanced registration with PRN & college fields
- ✅ LinkedIn OAuth callback handler
- ✅ Pending approvals endpoint
- ✅ Approve/reject endpoint
- ✅ Get colleges endpoint
- ✅ Approval status checks in login
File: backend/src/routes/auth.ts
- ✅ LinkedIn OAuth routes (
/linkedin,/linkedin/callback) - ✅ Admin approval routes (
/approvals/pending,/approvals/:id) - ✅ College search route (
/colleges)
File: backend/src/index.ts
- ✅ Session middleware integration
- ✅ Passport initialization
- ✅ passport
- ✅ passport-linkedin-oauth2
- ✅ express-session
- ✅ TypeScript type definitions
File: frontend/src/app/auth/register/page.tsx
- ✅ Username field (optional)
- ✅ PRN field (optional)
- ✅ Batch & Year dropdowns
- ✅ Department field
- ✅ College searchable dropdown
- ✅ LinkedIn OAuth button
- ✅ Real-time college search
File: frontend/src/contexts/AuthContext.tsx
- ✅ Updated register function to accept userData object
- ✅ Flexible registration data structure
File: frontend/src/app/admin/approvals/page.tsx
- ✅ View pending approval requests
- ✅ Display all user details (PRN, college, batch, etc.)
- ✅ Approve/Reject buttons
- ✅ LinkedIn badge indicator
- ✅ Protected route (admin only)
File: frontend/src/app/auth/pending-approval/page.tsx
- ✅ User-friendly pending status page
- ✅ Next steps information
- ✅ Token storage from LinkedIn callback
File: AUTHENTICATION_GUIDE.md
- ✅ Complete setup instructions
- ✅ API endpoints documentation
- ✅ User flows explained
- ✅ Database schema changes
- ✅ Security features
- ✅ Troubleshooting guide
File: backend/env.example
- ✅ LinkedIn OAuth credentials
- ✅ Session secret
- ✅ Frontend URL
- ✅ PRN-based registration with validation
- ✅ LinkedIn OAuth with auto college detection
- ✅ Admin approval workflow for students
- ✅ Username system for profile sharing
- ✅ College searchable database
- ✅ Batch, department, year tracking
- ✅ Approval status checks on login
- ✅ Protected admin routes
- ✅ Real-time pending requests dashboard
- Go to linkedin.com/developers
- Create a new app
- Get Client ID and Client Secret
- Update
backend/.env:LINKEDIN_CLIENT_ID=your-client-id LINKEDIN_CLIENT_SECRET=your-client-secret LINKEDIN_CALLBACK_URL=http://localhost:5000/api/auth/linkedin/callback SESSION_SECRET=your-session-secret FRONTEND_URL=http://localhost:3000
- The application will auto-create tables on startup
cd backend
npm run devcd frontend
npm run dev- Go to http://localhost:3000/auth/register
- Fill in all fields including PRN and college
- Submit → Should see pending approval message
- Create admin user (see below)
- Go to http://localhost:3000/admin/approvals
- Approve the request
- Login as the new user
- Go to http://localhost:3000/auth/register
- Click "Continue with LinkedIn"
- Authorize LinkedIn
- Should redirect to pending approval or home
UPDATE users
SET role = 'admin', approval_status = 'approved', verified = true
WHERE email = 'your-email@example.com';POST /api/auth/register- Register with optional college infoPOST /api/auth/login- LoginGET /api/auth/linkedin- Start LinkedIn OAuthGET /api/auth/colleges- Search colleges
GET /api/auth/profile- Get profilePUT /api/auth/profile- Update profile
GET /api/auth/approvals/pending- Get pending requestsPUT /api/auth/approvals/:id- Approve/rejectGET /api/auth/users- List usersPUT /api/auth/users/:id- Update user
DELETE /api/auth/users/:id- Delete user
- Password hashing with bcrypt (12 rounds)
- JWT authentication (7-day expiry)
- Session management for OAuth
- Rate limiting (100 req/15min)
- Input validation
- SQL injection protection
- CORS protection
CREATE TABLE colleges (
id UUID PRIMARY KEY,
name VARCHAR(255) UNIQUE NOT NULL,
domain VARCHAR(255),
city VARCHAR(100),
state VARCHAR(100),
created_at TIMESTAMP
);-- New fields added:
username VARCHAR(50) UNIQUE
prn VARCHAR(50) UNIQUE
batch VARCHAR(20)
department VARCHAR(100)
college_id UUID REFERENCES colleges(id)
year_of_study INTEGER
bio TEXT
avatar_url TEXT
verified BOOLEAN DEFAULT false
linkedin_id VARCHAR(255) UNIQUE
approval_status VARCHAR(20) -- 'pending', 'approved', 'rejected'
password_hash VARCHAR(255) -- Now optional for OAuth usersThe college-based authentication system is now fully functional with PRN verification, LinkedIn OAuth, and admin approval workflow.