feat: implement dfguide-registrar project with Postgres user registration functionality
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# dfguide-registrar
|
||||
|
||||
一个交互式 Rust CLI,用于向 [Delta Force Guide] 的 Postgres 数据库写入注册用户。
|
||||
|
||||
## 功能
|
||||
|
||||
- 从 `.env` 文件或系统环境变量读取 Postgres 连接信息
|
||||
- 交互式输入用户名、电子邮箱、密码
|
||||
- 当 `provider = LOCAL` 时,使用 Spring Security 兼容的 BCrypt 哈希保存密码
|
||||
- 以单个数据库事务写入 `app_user` 和 `app_user_credential`
|
||||
- 在写入前检查用户名和邮箱是否已存在
|
||||
|
||||
## 环境变量
|
||||
|
||||
支持两种配置方式:
|
||||
|
||||
1. 设置完整连接串 `PG_URL`
|
||||
2. 或分别设置以下变量:
|
||||
- `PG_HOST`
|
||||
- `PG_PORT`(可选,默认 `5432`)
|
||||
- `PG_USER`
|
||||
- `PG_PASSWORD`
|
||||
- `PG_DATABASE`
|
||||
|
||||
可以复制 `.env.example` 为 `.env` 后修改:
|
||||
|
||||
```powershell
|
||||
Copy-Item .env.example .env
|
||||
```
|
||||
|
||||
## 运行
|
||||
|
||||
```powershell
|
||||
cargo run
|
||||
```
|
||||
|
||||
程序会按顺序提示输入用户名、邮箱和密码。
|
||||
|
||||
## 测试
|
||||
|
||||
```powershell
|
||||
cargo test
|
||||
```
|
||||
|
||||
[Delta Force Guide]:https://dfguide.onixbyte.cn/
|
||||
Reference in New Issue
Block a user