mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-18 06:17:06 +00:00
添加锅巴用户数据
This commit is contained in:
parent
ae14be4cf5
commit
471da4f3b1
1 changed files with 17 additions and 2 deletions
|
|
@ -6,12 +6,26 @@ async function User(fastify, options) {
|
||||||
// 登录
|
// 登录
|
||||||
fastify.post('/login', async (request, reply) => {
|
fastify.post('/login', async (request, reply) => {
|
||||||
const body = request.body || {}
|
const body = request.body || {}
|
||||||
|
let guobaLoginService
|
||||||
|
let guobaAPI = ''
|
||||||
|
try {
|
||||||
|
let { LoginService } = await import('../../../../guoba-plugin/server/service/both/LoginService.js')
|
||||||
|
let { getAllWebAddress } = await import('../../../../guoba-plugin/utils/common.js')
|
||||||
|
guobaLoginService = new LoginService()
|
||||||
|
guobaAPI = await getAllWebAddress().remote
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
guobaLoginService = {
|
||||||
|
signToken: () => {return null}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (body.qq && body.passwd) {
|
if (body.qq && body.passwd) {
|
||||||
const token = randomString(32)
|
const token = randomString(32)
|
||||||
if (body.qq == getUin() && await redis.get('CHATGPT:ADMIN_PASSWD') == body.passwd) {
|
if (body.qq == getUin() && await redis.get('CHATGPT:ADMIN_PASSWD') == body.passwd) {
|
||||||
|
const guobaToken = await guobaLoginService.signToken(body.qq)
|
||||||
AddUser({ user: body.qq, token: token, autho: 'admin' })
|
AddUser({ user: body.qq, token: token, autho: 'admin' })
|
||||||
reply.setCookie('token', token, { path: '/' })
|
reply.setCookie('token', token, { path: '/' })
|
||||||
reply.send({ login: true, autho: 'admin', token: token })
|
reply.send({ login: true, autho: 'admin', token: token, guobaToken: guobaToken, guoba: guobaAPI })
|
||||||
} else {
|
} else {
|
||||||
const user = await getUserData(body.qq)
|
const user = await getUserData(body.qq)
|
||||||
if (user.passwd != '' && user.passwd === body.passwd) {
|
if (user.passwd != '' && user.passwd === body.passwd) {
|
||||||
|
|
@ -26,9 +40,10 @@ async function User(fastify, options) {
|
||||||
const token = randomString(32)
|
const token = randomString(32)
|
||||||
const opt = await redis.get(`CHATGPT:SERVER_QUICK`)
|
const opt = await redis.get(`CHATGPT:SERVER_QUICK`)
|
||||||
if (opt && body.otp == opt) {
|
if (opt && body.otp == opt) {
|
||||||
|
const guobaToken = await guobaLoginService.signToken(getUin())
|
||||||
AddUser({ user: getUin(), token: token, autho: 'admin' })
|
AddUser({ user: getUin(), token: token, autho: 'admin' })
|
||||||
reply.setCookie('token', token, { path: '/' })
|
reply.setCookie('token', token, { path: '/' })
|
||||||
reply.send({ login: true, autho: 'admin', token: token, user: getUin() })
|
reply.send({ login: true, autho: 'admin', token: token, user: getUin(), guobaToken: guobaToken, guoba: guobaAPI })
|
||||||
} else {
|
} else {
|
||||||
reply.send({ login: false, err: `快捷登录代码错误,请检查后重试` })
|
reply.send({ login: false, err: `快捷登录代码错误,请检查后重试` })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue