Commit b2bb800d authored by 任国军's avatar 任国军

add decoded

parent 2a1a6964
Pipeline #18000 passed with stage
in 6 seconds
...@@ -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);
} }
......
...@@ -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;
......
...@@ -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.phoneNumber)) {
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;
......
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment