|
| 1 | +### 🎫 TICKET #2: Member Application System Implementation |
| 2 | + |
| 3 | +**Assignee:** Developer 2 |
| 4 | +**Priority:** High |
| 5 | +**Estimated Effort:** 4-5 days |
| 6 | +**Type:** Backend + Frontend Feature |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +### 📋 Description |
| 11 | +Replace the current direct user registration with a member application system. Users submit applications with basic information and organization code, then wait for admin approval before gaining access to the platform. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +### 🎯 Acceptance Criteria |
| 16 | +✅ New application status field added to User model |
| 17 | +✅ Application form replaces registration form |
| 18 | +✅ Pending applications show "Approval Awaiting" message |
| 19 | +✅ Restricted access for pending members |
| 20 | +✅ Database migration for existing users |
| 21 | +✅ API endpoints for application submission |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +### 📊 Database Schema Changes |
| 26 | +Update User Model (`/server/mongodb/models/User/index.ts`): |
| 27 | +```javascript |
| 28 | +// Add new field to userSchema |
| 29 | +applicationStatus: { |
| 30 | + type: String, |
| 31 | + enum: ["pending", "approved", "rejected"], |
| 32 | + default: "pending" |
| 33 | +}, |
| 34 | +appliedAt: { type: Date, default: Date.now }, |
| 35 | +approvedAt: { type: Date }, |
| 36 | +approvedBy: { |
| 37 | + type: Schema.Types.ObjectId, |
| 38 | + ref: "User" |
| 39 | +}, |
| 40 | +rejectionReason: { type: String } |
| 41 | +``` |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +### 🔧 Backend Implementation |
| 46 | +Create Migration Script: |
| 47 | +```javascript |
| 48 | +// /server/mongodb/migrations/add-application-status.js |
| 49 | +// Set existing users to "approved" status |
| 50 | +``` |
| 51 | + |
| 52 | +Update User Creation Logic: |
| 53 | +- `/server/actions/users_new.ts` |
| 54 | +- Modify `createUserFromCredentials` |
| 55 | +- Set new users to "pending" status |
| 56 | +- Remove automatic organization assignment |
| 57 | + |
| 58 | +New API Endpoints: |
| 59 | +```javascript |
| 60 | +// /src/pages/api/applications/submit.ts |
| 61 | +POST /api/applications/submit |
| 62 | + |
| 63 | +// /src/pages/api/applications/[id]/status.ts |
| 64 | +PUT /api/applications/[id]/status |
| 65 | +``` |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +### 🎨 Frontend Implementation |
| 70 | +Application Form (`/src/screens/Auth/ApplicationForm.jsx`): |
| 71 | +```jsx |
| 72 | +// Replace registration with application form |
| 73 | +- Remove password fields |
| 74 | +- Add application-specific messaging |
| 75 | +- Submit to new application endpoint |
| 76 | +``` |
| 77 | + |
| 78 | +Pending Status Page (`/src/screens/Members/PendingApproval.jsx`): |
| 79 | +```jsx |
| 80 | +// Show "Approval Awaiting" message |
| 81 | +// Display application submission date |
| 82 | +// Provide contact information for questions |
| 83 | +``` |
| 84 | + |
| 85 | +Access Control Middleware: |
| 86 | +```javascript |
| 87 | +// /src/middleware/checkApplicationStatus.js |
| 88 | +// Redirect pending users to waiting page |
| 89 | +// Block access to events and main features |
| 90 | +``` |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### 🔒 Access Control Logic |
| 95 | +```javascript |
| 96 | +// In main layout component |
| 97 | +if (user.applicationStatus === "pending") { |
| 98 | + return <PendingApprovalPage />; |
| 99 | +} |
| 100 | +if (user.applicationStatus === "rejected") { |
| 101 | + return <ApplicationRejectedPage />; |
| 102 | +} |
| 103 | +// Continue with normal app flow |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +### 📁 Files to Create/Modify |
| 109 | +**New Files:** |
| 110 | +- `/src/screens/Auth/ApplicationForm.jsx` |
| 111 | +- `/src/screens/Members/PendingApproval.jsx` |
| 112 | +- `/src/screens/Members/ApplicationRejected.jsx` |
| 113 | +- `/src/pages/api/applications/submit.ts` |
| 114 | +- `/server/mongodb/migrations/add-application-status.js` |
| 115 | + |
| 116 | +**Modified Files:** |
| 117 | +- `/server/mongodb/models/User/index.ts` |
| 118 | +- `/server/actions/users_new.ts` |
| 119 | +- `/src/screens/Auth/AuthPage.jsx` |
| 120 | +- `/src/pages/api/users/index.ts` |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +### 🧪 Testing Requirements |
| 125 | +✅ New applications create pending users |
| 126 | +✅ Pending users see waiting message |
| 127 | +✅ Pending users cannot access events |
| 128 | +✅ Application form validation works |
| 129 | +✅ Database migration runs successfully |
| 130 | +✅ Existing users remain unaffected |
0 commit comments