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
b2bb800d
Commit
b2bb800d
authored
Dec 10, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add decoded
parent
2a1a6964
Pipeline
#18000
passed with stage
in 6 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
8 deletions
+10
-8
user.js
app/controller/course/v2/user.js
+2
-2
mini_auth_v2.js
app/middleware/mini_auth_v2.js
+2
-2
user.js
app/service/course/v2/user.js
+5
-4
wechat.js
app/service/course/v2/wechat.js
+1
-0
No files found.
app/controller/course/v2/user.js
View file @
b2bb800d
...
@@ -34,7 +34,7 @@ class UserController extends Controller {
...
@@ -34,7 +34,7 @@ class UserController extends Controller {
ctx
.
set
(
'uuid'
,
key
);
ctx
.
set
(
'uuid'
,
key
);
ctx
.
set
(
'auth_token'
,
auth_token
);
ctx
.
set
(
'auth_token'
,
auth_token
);
const
result
=
{
uuid
:
user_uuid
,
auth_token
,
session_key
};
const
result
=
{
uuid
:
user_uuid
,
auth_token
};
ctx
.
success
({
result
});
ctx
.
success
({
result
});
...
@@ -48,7 +48,7 @@ class UserController extends Controller {
...
@@ -48,7 +48,7 @@ class UserController extends Controller {
const
iv
=
input_params
.
iv
||
''
;
const
iv
=
input_params
.
iv
||
''
;
const
params
=
{
avatar
,
nickname
,
province
,
country
,
sex
,
city
,
encryptedData
,
iv
};
const
params
=
{
avatar
,
nickname
,
province
,
country
,
sex
,
city
,
encryptedData
,
iv
};
const
ret
=
await
service
.
course
.
v2
.
registerUserInfo
(
params
);
const
ret
=
await
service
.
course
.
v2
.
user
.
registerUserInfo
(
params
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
...
...
app/middleware/mini_auth_v2.js
View file @
b2bb800d
...
@@ -8,11 +8,11 @@ module.exports = (options, app) => {
...
@@ -8,11 +8,11 @@ module.exports = (options, app) => {
const
key
=
'course_v2_user_session_'
+
uuid
;
const
key
=
'course_v2_user_session_'
+
uuid
;
let
auth_info
=
await
ctx
.
app
.
memcache
.
get
(
key
);
let
auth_info
=
await
ctx
.
app
.
memcache
.
get
(
key
);
if
(
!
auth_info
)
{
if
(
!
auth_info
)
{
auth_info
=
await
ctx
.
classModel
.
V2
.
CourseUser
.
findOne
({
where
:
{
uuid
}
});
auth_info
=
await
ctx
.
classModel
.
V2
.
CourseUser
.
findOne
({
where
:
{
uuid
}
});
if
(
ctx
.
isEmpty
(
auth_info
))
{
if
(
ctx
.
isEmpty
(
auth_info
))
{
ctx
.
failed
(
'user not exist'
);
ctx
.
failed
(
'user not exist'
);
}
else
{
}
else
{
await
ctx
.
app
.
memcache
.
set
(
key
,
{
user_uuid
:
uuid
,
openid
:
auth_info
.
openid
},
86400
*
7
);
await
ctx
.
app
.
memcache
.
set
(
key
,
{
user_uuid
:
uuid
,
openid
:
auth_info
.
openid
},
86400
*
7
);
}
}
}
}
const
openid
=
auth_info
.
openid
;
const
openid
=
auth_info
.
openid
;
...
...
app/service/course/v2/user.js
View file @
b2bb800d
...
@@ -146,6 +146,7 @@ class UserService extends Service {
...
@@ -146,6 +146,7 @@ class UserService extends Service {
}
}
const
data
=
{};
const
data
=
{};
let
bind_phone
=
ctx
.
isEmpty
(
user
.
phone
)
?
0
:
1
;
if
(
!
ctx
.
isEmpty
(
avatar
))
{
if
(
!
ctx
.
isEmpty
(
avatar
))
{
data
.
avatar
=
avatar
;
data
.
avatar
=
avatar
;
}
}
...
@@ -155,9 +156,9 @@ class UserService extends Service {
...
@@ -155,9 +156,9 @@ class UserService extends Service {
if
(
!
ctx
.
isEmpty
(
encryptedData
)
&&
!
ctx
.
isEmpty
(
iv
))
{
if
(
!
ctx
.
isEmpty
(
encryptedData
)
&&
!
ctx
.
isEmpty
(
iv
))
{
const
decoded
=
await
ctx
.
service
.
course
.
v2
.
wechat
.
decodeData
(
encryptedData
,
iv
);
const
decoded
=
await
ctx
.
service
.
course
.
v2
.
wechat
.
decodeData
(
encryptedData
,
iv
);
if
(
!
ctx
.
isEmpty
(
decoded
)
&&
!
ctx
.
isEmpty
(
decoded
.
phone
))
{
if
(
!
ctx
.
isEmpty
(
decoded
)
&&
!
ctx
.
isEmpty
(
decoded
.
phone
Number
))
{
console
.
log
(
decoded
)
;
data
.
phone
=
decoded
.
phoneNumber
;
data
.
phone
=
decoded
.
phone
;
bind_phone
=
1
;
}
}
}
}
...
@@ -165,7 +166,7 @@ class UserService extends Service {
...
@@ -165,7 +166,7 @@ class UserService extends Service {
const
ret
=
{
const
ret
=
{
result
:
{
result
:
{
bind_phone
:
0
,
bind_phone
,
},
},
};
};
return
ret
;
return
ret
;
...
...
app/service/course/v2/wechat.js
View file @
b2bb800d
...
@@ -146,6 +146,7 @@ class WechatService extends Service {
...
@@ -146,6 +146,7 @@ class WechatService extends Service {
if
(
ctx
.
isEmpty
(
userInfo
)
||
ctx
.
isEmpty
(
userInfo
.
session_key
))
{
if
(
ctx
.
isEmpty
(
userInfo
)
||
ctx
.
isEmpty
(
userInfo
.
session_key
))
{
ctx
.
failed
(
'sessionKey不存在'
);
ctx
.
failed
(
'sessionKey不存在'
);
}
}
const
sessionKey
=
new
Buffer
(
userInfo
.
session_key
,
'base64'
);
const
sessionKey
=
new
Buffer
(
userInfo
.
session_key
,
'base64'
);
// base64 decode
// base64 decode
...
...
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