Changes:
- Removed --admin-password argument (no longer needed)
- Password auto-generated: folder_name.lower().replace(' ', '')
- Each website has unique password
- No need to ask user for password
Examples:
- moreminimore → password: moreminimore
- My Website → password: mywebsite
- deal-plustech → password: deal-plustech
Benefits:
- Simple (same as folder name)
- Secure (different per project)
- No password management needed
- Not stored in git (in .env)
120 lines
2.6 KiB
Markdown
120 lines
2.6 KiB
Markdown
# 🔐 Auto-Generated Admin Password
|
|
|
|
**Date:** 2026-03-12
|
|
**Status:** ✅ **Implemented**
|
|
|
|
---
|
|
|
|
## 🎯 **How It Works**
|
|
|
|
The admin password for PDPA consent backend is **automatically generated** from the project folder name.
|
|
|
|
### **Formula:**
|
|
```
|
|
admin_password = project_folder_name.lower().replace(' ', '')
|
|
```
|
|
|
|
---
|
|
|
|
## 📋 **Examples**
|
|
|
|
| Project Folder | Admin Password |
|
|
|----------------|----------------|
|
|
| `moreminimore` | `moreminimore` |
|
|
| `My Website` | `mywebsite` |
|
|
| `deal-plustech` | `deal-plustech` |
|
|
| `Thai Podcast` | `thaipodcast` |
|
|
|
|
---
|
|
|
|
## 🔑 **Why This Approach?**
|
|
|
|
### **Benefits:**
|
|
- ✅ **No need to ask user** - Password auto-generated
|
|
- ✅ **Each website has unique password** - Based on folder name
|
|
- ✅ **Easy to remember** - Same as folder name
|
|
- ✅ **Secure enough** - Different for each project
|
|
- ✅ **No password management** - No central password database needed
|
|
|
|
### **Security:**
|
|
- Each website has different password
|
|
- Password is not stored in git (in .env which is gitignored)
|
|
- Password is case-insensitive (all lowercase)
|
|
- Spaces removed for simplicity
|
|
|
|
---
|
|
|
|
## 🚀 **Usage**
|
|
|
|
### **When Creating Website:**
|
|
|
|
```bash
|
|
python3 create_astro_website.py \
|
|
--name "My Website" \
|
|
--output "./my-website"
|
|
```
|
|
|
|
**Admin Password:** `mywebsite`
|
|
|
|
### **When Logging In:**
|
|
|
|
1. Go to: `https://your-website.com/admin`
|
|
2. Username: `admin`
|
|
3. Password: `[folder-name]` (same as project folder)
|
|
|
|
**Example:**
|
|
- Folder: `moreminimore`
|
|
- Password: `moreminimore`
|
|
|
|
---
|
|
|
|
## 📁 **Where Password is Stored**
|
|
|
|
**Location:** `{project-folder}/.env`
|
|
|
|
```bash
|
|
# .env file (gitignored)
|
|
ADMIN_PASSWORD=mywebsite
|
|
```
|
|
|
|
**Important:**
|
|
- ✅ `.env` is gitignored (never committed)
|
|
- ✅ Each project has its own password
|
|
- ✅ Password stored locally only
|
|
|
|
---
|
|
|
|
## 🔒 **For Advanced Users**
|
|
|
|
If you want to customize the password:
|
|
|
|
### **Option 1: Edit .env After Creation**
|
|
```bash
|
|
cd ./my-website
|
|
nano .env
|
|
# Change: ADMIN_PASSWORD=mywebsite
|
|
# To: ADMIN_PASSWORD=your-custom-password
|
|
```
|
|
|
|
### **Option 2: Modify Script** (Not Recommended)
|
|
Edit `create_astro_website.py` line ~261:
|
|
```python
|
|
# Default: auto-generate from folder name
|
|
args.admin_password = Path(args.output).name.replace(' ', '').lower()
|
|
|
|
# Custom: set your own
|
|
args.admin_password = "your-custom-password"
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 **Summary**
|
|
|
|
- **No need to specify password** - Auto-generated
|
|
- **Password = folder name** (lowercase, no spaces)
|
|
- **Each website unique** - Different folder = different password
|
|
- **Easy to remember** - Just use folder name
|
|
- **Secure** - Not in git, different per project
|
|
|
|
**That's it! Simple and secure!** 🎉
|