Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
fix: 🐛 修复因为未触发scan事件导致token未初始化可无鉴权访问/login的问题 close:#102 (#103)
Browse files Browse the repository at this point in the history
✅ Closes: 102 问题版本 v2.4.0, v2.4.1
  • Loading branch information
danni-cool authored Dec 29, 2023
2 parents c88a888 + 73a55e4 commit 2891e41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/service/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const sendMsg2RecvdApi = async function (msg) {
}

// 得到 loginAPIToken
const getLoginApiToken = () => {
const initLoginApiToken = () => {
if (!process.env.globalLoginToken) {
process.env.globalLoginToken = LOGIN_API_TOKEN || LOCAL_LOGIN_API_TOKEN
}
Expand All @@ -172,5 +172,5 @@ const getLoginApiToken = () => {

module.exports = {
sendMsg2RecvdApi,
getLoginApiToken,
initLoginApiToken,
}
3 changes: 2 additions & 1 deletion src/wechaty/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { WechatyBuilder } = require('wechaty')
const Service = require('../service')
const chalk = require('chalk')
const { PORT } = process.env
const token = Service.initLoginApiToken()
const bot =
process.env.DISABLE_AUTO_LOGIN === 'true'
? WechatyBuilder.build()
Expand All @@ -18,7 +19,7 @@ module.exports = function init() {
[
'Access the URL to login: ' +
chalk.cyan(
`http://localhost:${PORT}/login?token=${Service.getLoginApiToken()}`,
`http://localhost:${PORT}/login?token=${token}`,
),
].join('\n'),
),
Expand Down

0 comments on commit 2891e41

Please sign in to comment.