feat: Auto-generate admin password from project folder name

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)
This commit is contained in:
Kunthawat Greethong
2026-03-12 09:53:17 +07:00
parent 61321669d1
commit 6e183c584b
3 changed files with 123 additions and 3 deletions

View File

@@ -0,0 +1,119 @@
# 🔐 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!** 🎉