fix: improve admin credentials display and configuration
Mirror to GitHub / mirror (push) Successful in 29s
Test and Lint / backend-test (push) Successful in 1m32s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m5s
Version and Release / version-bump (push) Successful in 42s
Version and Release / trigger-drone (push) Successful in 3s
Mirror to GitHub / mirror (push) Successful in 29s
Test and Lint / backend-test (push) Successful in 1m32s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m5s
Version and Release / version-bump (push) Successful in 42s
Version and Release / trigger-drone (push) Successful in 3s
- Display email address instead of username in migration output - Use environment variables for admin email configuration - Update deployment guide with clear admin setup instructions - Add note that login requires email address, not username - Fix GitHub URL to correct repository - Remove obsolete version field from docker-compose.yml 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+52
-6
@@ -23,8 +23,8 @@ This guide covers deploying PicPeak using Docker Compose with direct port exposu
|
|||||||
|
|
||||||
1. **Clone the repository**
|
1. **Clone the repository**
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/yourusername/wedding-photo-sharing.git
|
git clone https://github.com/the-luap/picpeak.git
|
||||||
cd wedding-photo-sharing
|
cd picpeak
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Set up environment**
|
2. **Set up environment**
|
||||||
@@ -119,20 +119,66 @@ By default, services are exposed on:
|
|||||||
|
|
||||||
### Initial Admin Setup
|
### Initial Admin Setup
|
||||||
|
|
||||||
The admin credentials are generated during first startup. Check the logs:
|
When deploying for the first time, an admin account is automatically created with a secure random password. You need to retrieve this password to access the admin panel.
|
||||||
|
|
||||||
|
#### Finding the Admin Password
|
||||||
|
|
||||||
|
**Option 1: Check the backend logs** (recommended)
|
||||||
```bash
|
```bash
|
||||||
docker compose logs backend | grep -A 5 "Admin user created"
|
# View the initial setup logs
|
||||||
|
docker compose logs backend | grep -A 10 "Admin user created"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or use the helper script:
|
You should see output like:
|
||||||
|
```
|
||||||
|
========================================
|
||||||
|
✅ Admin user created successfully!
|
||||||
|
========================================
|
||||||
|
Email: admin@example.com
|
||||||
|
Password: BraveTiger6231!
|
||||||
|
|
||||||
|
⚠️ IMPORTANT:
|
||||||
|
1. Save these credentials securely
|
||||||
|
2. Please change the password after first login
|
||||||
|
========================================
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**: You login with the **email address**, not a username!
|
||||||
|
|
||||||
|
**Option 2: Check the saved credentials file**
|
||||||
```bash
|
```bash
|
||||||
|
# The password is saved in the backend container
|
||||||
|
docker exec picpeak-backend cat data/ADMIN_CREDENTIALS.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
**Option 3: Use the helper script**
|
||||||
|
```bash
|
||||||
|
# Show current admin username and email (password is hidden)
|
||||||
docker exec picpeak-backend node scripts/show-admin-credentials.js
|
docker exec picpeak-backend node scripts/show-admin-credentials.js
|
||||||
|
|
||||||
# To reset password
|
# Reset the admin password to a new random password
|
||||||
docker exec picpeak-backend node scripts/show-admin-credentials.js --reset
|
docker exec picpeak-backend node scripts/show-admin-credentials.js --reset
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Important Notes
|
||||||
|
|
||||||
|
- **Login requires the email address**, not username
|
||||||
|
- The admin password is only shown once during initial setup
|
||||||
|
- If you lose the password, use the `--reset` option to generate a new one
|
||||||
|
- You must change the password on first login (enforced by the system)
|
||||||
|
- Password requirements: minimum 12 characters, mixed case, numbers, and special characters
|
||||||
|
|
||||||
|
#### Configuring Admin Email
|
||||||
|
|
||||||
|
By default, the admin email is `admin@example.com`. To use a different email address, set it in your `.env` file before first deployment:
|
||||||
|
|
||||||
|
```env
|
||||||
|
# .env
|
||||||
|
ADMIN_EMAIL=your-email@yourdomain.com
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**: This only works on first deployment. To change the admin email after deployment, you'll need to update it in the database or create a new admin user through the admin panel.
|
||||||
|
|
||||||
## 🔒 Reverse Proxy Setup
|
## 🔒 Reverse Proxy Setup
|
||||||
|
|
||||||
For production deployments, you should use a reverse proxy for SSL/HTTPS. The application exposes ports directly, allowing you to use any reverse proxy solution.
|
For production deployments, you should use a reverse proxy for SSL/HTTPS. The application exposes ports directly, allowing you to use any reverse proxy solution.
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ exports.up = async function(knex) {
|
|||||||
const generatedPassword = generateReadablePassword();
|
const generatedPassword = generateReadablePassword();
|
||||||
const passwordHash = await bcrypt.hash(generatedPassword, 12); // Increased rounds for better security
|
const passwordHash = await bcrypt.hash(generatedPassword, 12); // Increased rounds for better security
|
||||||
|
|
||||||
|
// Get admin credentials from environment or use defaults
|
||||||
|
const adminUsername = process.env.ADMIN_USERNAME || 'admin';
|
||||||
|
const adminEmail = process.env.ADMIN_EMAIL || 'admin@example.com';
|
||||||
|
|
||||||
await knex('admin_users').insert({
|
await knex('admin_users').insert({
|
||||||
username: 'admin',
|
username: adminUsername,
|
||||||
email: 'admin@example.com',
|
email: adminEmail,
|
||||||
password_hash: passwordHash,
|
password_hash: passwordHash,
|
||||||
created_at: new Date()
|
created_at: new Date()
|
||||||
});
|
});
|
||||||
@@ -36,7 +40,7 @@ PicPeak Admin Credentials
|
|||||||
|
|
||||||
Your admin account has been created with these credentials:
|
Your admin account has been created with these credentials:
|
||||||
|
|
||||||
Username: admin
|
Email: ${adminEmail}
|
||||||
Password: ${generatedPassword}
|
Password: ${generatedPassword}
|
||||||
|
|
||||||
IMPORTANT SECURITY NOTES:
|
IMPORTANT SECURITY NOTES:
|
||||||
@@ -47,6 +51,8 @@ IMPORTANT SECURITY NOTES:
|
|||||||
|
|
||||||
Login URL: ${process.env.ADMIN_URL || 'http://localhost:3001'}/admin
|
Login URL: ${process.env.ADMIN_URL || 'http://localhost:3001'}/admin
|
||||||
|
|
||||||
|
Login with the email address shown above
|
||||||
|
|
||||||
Generated on: ${new Date().toISOString()}
|
Generated on: ${new Date().toISOString()}
|
||||||
========================================
|
========================================
|
||||||
`;
|
`;
|
||||||
@@ -65,7 +71,7 @@ Generated on: ${new Date().toISOString()}
|
|||||||
console.log('\n========================================');
|
console.log('\n========================================');
|
||||||
console.log('✅ Admin user created successfully!');
|
console.log('✅ Admin user created successfully!');
|
||||||
console.log('========================================');
|
console.log('========================================');
|
||||||
console.log('Username: admin');
|
console.log(`Email: ${adminEmail}`);
|
||||||
console.log(`Password: ${generatedPassword}`);
|
console.log(`Password: ${generatedPassword}`);
|
||||||
console.log('\n⚠️ IMPORTANT:');
|
console.log('\n⚠️ IMPORTANT:');
|
||||||
console.log('1. Save these credentials securely');
|
console.log('1. Save these credentials securely');
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
build:
|
build:
|
||||||
|
|||||||
Reference in New Issue
Block a user