Skip to content

Commit

Permalink
feat: 添加注册登录&同步聊天数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin committed Mar 14, 2023
1 parent 3a1466b commit 0cccd04
Show file tree
Hide file tree
Showing 27 changed files with 1,095 additions and 163 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ coverage

# Environment variables files
/service/.env
/docker-compose/nginx/html
41 changes: 40 additions & 1 deletion docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
image: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可
ports:
- 3002:3002
depends_on:
- database
environment:
# 二选一
OPENAI_API_KEY: xxxx
Expand All @@ -16,7 +18,7 @@ services:
OPENAI_API_MODEL: xxxx
# 反向代理,可选
API_REVERSE_PROXY: xxx
# 访问权限密钥,可选
# 访问jwt加密参数,可选 不为空则允许登录 同时需要设置 MONGODB_URL
AUTH_SECRET_KEY: xxx
# 超时,单位毫秒,可选
TIMEOUT_MS: 60000
Expand All @@ -26,6 +28,40 @@ services:
SOCKS_PROXY_PORT: xxxx
# HTTPS_PROXY 代理,可选
HTTPS_PROXY: http://xxxx:7890
# mongodb 的连接字符串
MONGODB_URL: 'mongodb://chatgpt:xxxx@database:27017'
# 网站是否开启注册
REGISTER_ENABLED: false
# 开启注册之后 网站注册允许的邮箱后缀 如果空 则允许任意后缀
REGISTER_MAILS: '@qq.com,@sina.com,@163.com'
# 开启注册之后 密码加密的盐
PASSWORD_MD5_SALT: anysalt
# 开启注册之后 超级管理邮箱
ROOT_USER: xxx@qq.com
# 开启注册之后 网站域名 不含 / 注册的时候发送验证邮箱使用
SITE_DOMAIN: http://127.0.0.1:1002
# 开启注册之后 发送验证邮箱配置
SMTP_HOST: smtp.exmail.qq.com
SMTP_PORT: 465
SMTP_TSL: true
SMTP_USERNAME: ${SMTP_USERNAME}
SMTP_PASSWORD: ${SMTP_PASSWORD}
links:
- database

database:
image: mongo
ports:
- '27017:27017'
expose:
- '27017'
volumes:
- mongodb:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: chatgpt
MONGO_INITDB_ROOT_PASSWORD: xxxx
MONGO_INITDB_DATABASE: chatgpt

nginx:
image: nginx:alpine
ports:
Expand All @@ -37,3 +73,6 @@ services:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
links:
- app

volumes:
mongodb: {}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@vueuse/core": "^9.13.0",
"highlight.js": "^11.7.0",
"html2canvas": "^1.4.1",
"jwt-decode": "^3.1.2",
"katex": "^0.16.4",
"markdown-it": "^13.0.1",
"naive-ui": "^2.34.3",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 36 additions & 3 deletions service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ API_REVERSE_PROXY=
# timeout
TIMEOUT_MS=100000

# Secret key
AUTH_SECRET_KEY=

# Socks Proxy Host
SOCKS_PROXY_HOST=

Expand All @@ -27,3 +24,39 @@ SOCKS_PROXY_PORT=

# HTTPS PROXY
HTTPS_PROXY=

# Databse connection string
# MONGODB_URL=mongodb://chatgpt:xxxx@yourip:port
MONGODB_URL=mongodb://chatgpt:xxxx@database:27017

# Secret key for jwt
# If not empty, will need login
AUTH_SECRET_KEY=

# ----- Only valid after setting AUTH_SECRET_KEY begin ----

# Allow anyone register
REGISTER_ENABLED=false

# The site domain, Only for registration account verification
# without end /
SITE_DOMAIN=http://127.0.0.1:1002

# Allowed Email Providers, If it is empty, any mailbox is allowed
# REGISTER_MAILS=@qq.com,@sina.com,@163.com
REGISTER_MAILS=@qq.com,@sina.com,@163.com

# The roon user only email
ROOT_USER=

# Password salt
PASSWORD_MD5_SALT=anysalt

# User register email verify
SMTP_HOST=smtp.exmail.qq.com
SMTP_PORT=465
SMTP_TSL=true
SMTP_USERNAME=yourname@example.com
SMTP_PASSWORD=yourpassword

# ----- Only valid after setting AUTH_SECRET_KEY end ----
4 changes: 4 additions & 0 deletions service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@
"express": "^4.18.2",
"https-proxy-agent": "^5.0.1",
"isomorphic-fetch": "^3.0.0",
"mongodb": "^5.1.0",
"node-fetch": "^3.3.0",
"nodemailer": "^6.9.1",
"socks-proxy-agent": "^7.0.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.35.3",
"@types/express": "^4.17.17",
"@types/mongodb": "^4.0.7",
"@types/node": "^18.14.6",
"eslint": "^8.35.0",
"jsonwebtoken": "^9.0.0",
"rimraf": "^4.3.0",
"tsup": "^6.6.3",
"typescript": "^4.9.5"
Expand Down
Loading

0 comments on commit 0cccd04

Please sign in to comment.