implement /setup and /admin

This commit is contained in:
2026-01-23 02:52:53 +01:00
parent e4e5a1c294
commit a9c70a7883
21 changed files with 1124 additions and 13 deletions
+34
View File
@@ -0,0 +1,34 @@
# Admin Dashboard
The admin dashboard provides tools for managing users, invitations, and viewing system statistics.
## Creating the First Admin User
Visit /setup
## Accessing the Admin Dashboard
1. **Note:** Authentication system is not yet implemented. You'll need to set `session[:user_id]` manually in the console or implement the authentication controllers first.
2. Once authenticated, navigate to `/admin` to access the dashboard.
## Admin Features
### Dashboard (`/admin`)
- View system statistics (users, entries, suggestions)
- Language completion percentages
- Recent activity (new users, new entries)
- Pending invitations count
### User Management (`/admin/users`)
- List all users with filtering
- Edit user details and roles
- Delete users (except yourself)
- View user status (active/invited)
### Invitations (`/admin/invitations`)
- Send new invitations
- View pending invitations (not yet accepted)
- Cancel pending invitations
- View recently accepted invitations
- Invitations expire after 14 days
+74
View File
@@ -0,0 +1,74 @@
# Setup Guide
## Initial Setup
When you first deploy Sanasto Wiki, you need to create an initial administrator account.
### Automatic Setup (Recommended)
1. Start the Rails server:
```bash
bundle exec rails server
```
2. Navigate to `/setup` in your browser
3. Fill in the setup form:
- **Name**: Your full name
- **Email**: Your email address (becomes the system default contact)
- **Preferred Language**: Your primary working language
- **Password**: At least 12 characters
- **Confirm Password**: Re-enter your password
4. Click "Complete Setup"
5. You'll be automatically logged in and redirected to the admin dashboard
### What Happens During Setup
- Creates your admin account with full permissions
- Sets you as the default system contact (User.first.email)
- Creates a `.installed` marker file to prevent re-running setup
- Automatically logs you in
- Protects your account from deletion (first user cannot be deleted)
### After Setup
Once setup is complete:
- The `/setup` route becomes inaccessible
- You can access the admin dashboard at `/admin`
- You can invite other users through the admin interface
- The first admin user (you) is protected from deletion
### Resetting Setup
If you need to re-run setup (e.g., in development):
```bash
# Remove the installed marker
rm .installed
# Clear the database (development only!)
bundle exec rails db:reset
# Now you can access /setup again
```
### Production Deployment
For production deployment:
1. Deploy the application
2. Run migrations: `bundle exec rails db:migrate`
3. Navigate to your domain's `/setup` route
4. Complete the setup form
5. Start inviting contributors
The `.installed` file should NOT be committed to version control (it's in .gitignore).
### Security Notes
- The setup route is only accessible when `.installed` file doesn't exist
- Password must be at least 12 characters
- The first admin user cannot be deleted through the UI
- Setup automatically creates an admin-level account
- After setup, use the invitation system to add more users
+5 -4
View File
@@ -54,10 +54,11 @@
## User Management
- [ ] **Admin dashboard**
- [ ] Send invitations by email
- [ ] Manage users (list, edit roles, deactivate)
- [ ] System statistics (users, entries, contributions)
- [x] **Setup** adds the first user
- [x] **Admin dashboard**
- [x] Send invitations interface (email delivery pending mailer implementation)
- [x] Manage users (list, edit roles, delete)
- [x] System statistics (users, entries, contributions)
- [ ] **User profile page**
- [ ] Edit name, email, password
- [ ] Set primary language preference