Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
e700a7bd
Commit
e700a7bd
authored
Oct 23, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wechat check
parent
aec897e6
Pipeline
#15259
passed with stage
in 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
wechat.js
app/controller/course/wechat.js
+29
-3
course.js
app/router/course.js
+2
-2
No files found.
app/controller/course/wechat.js
View file @
e700a7bd
...
...
@@ -10,9 +10,35 @@ class WechatController extends Controller {
}
async
callbackAction
()
{
const
{
ctx
,
service
}
=
this
;
await
service
.
course
.
wechat
.
callbackAction
();
ctx
.
success
();
const
{
ctx
,
service
}
=
this
;
await
service
.
course
.
wechat
.
callbackAction
();
ctx
.
success
(
'success'
);
}
async
check
()
{
const
{
ctx
}
=
this
;
const
params
=
ctx
.
request
.
query
;
const
{
signature
,
timestamp
,
nonce
,
echostr
,
}
=
params
;
const
array
=
[
'51gjj'
,
timestamp
,
nonce
];
array
.
sort
();
// 3.将三个参数字符串拼接成一个字符串进行sha1加密
const
tempStr
=
array
.
join
(
''
);
const
hashCode
=
crypto
.
createHash
(
'sha1'
);
// 创建加密类型
const
resultCode
=
hashCode
.
update
(
tempStr
,
'utf8'
).
digest
(
'hex'
);
// 4.开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
if
(
resultCode
===
signature
)
{
ctx
.
success
(
echostr
);
}
else
{
ctx
.
failed
();
}
}
}
...
...
app/router/course.js
View file @
e700a7bd
...
...
@@ -28,6 +28,6 @@ module.exports = app => {
router
.
post
(
'third'
,
'/user/collection/institution'
,
miniAuth
,
'course.user.collectInstitution'
);
// 收藏机构
router
.
delete
(
'third'
,
'/user/collection/institution'
,
miniAuth
,
'course.user.delCollectInstitution'
);
// 取消收藏机构
router
.
get
(
'third'
,
'/wechat/callbackAction'
,
'course.wechat.c
allbackAction
'
);
router
.
get
(
'third'
,
'/wechat/callbackAction'
,
'course.wechat.c
heck
'
);
router
.
post
(
'third'
,
'/wechat/callbackAction'
,
miniAuth
,
'course.wechat.callbackAction'
);
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment