企微考试提交
This commit is contained in:
20
src/rest/wxtest/action.js
Normal file
20
src/rest/wxtest/action.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const {getSignature, decrypt} = require("@wecom/crypto");
|
||||
const {addOrUpdate} = require("../../utils/dbUitls");
|
||||
const token = "pnYAdXEHYzYhIyzE6Qbs2L"
|
||||
const encodingAESKey = "fHkOHrUGSVUmPjFmshLEFN2XbaqF3OxsuYgnJu6DB1G"
|
||||
module.exports = {
|
||||
action: "/node/wxtest/action",
|
||||
method: "post",
|
||||
execute: (request, response) => {
|
||||
const {msg_signature, timestamp, nonce, echostr} = request.query
|
||||
const signature = getSignature(token, timestamp, nonce, echostr);
|
||||
if (msg_signature == signature) {
|
||||
const context = decrypt(encodingAESKey, echostr)
|
||||
const {name, mobile: phone, email, userId} = context
|
||||
addOrUpdate({
|
||||
table: "sys_user", form: {name, email, phone, userId}
|
||||
})
|
||||
response.send({code: 0, message: "success"})
|
||||
}else response.send({code: 1, message: "error"})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user