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
e72842a2
Commit
e72842a2
authored
Jul 23, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix old_app userLogin
parent
6cfe9530
Pipeline
#26732
passed with stage
in 4 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
user.js
app/service/course/v5/user.js
+8
-1
user.js
app/service/user.js
+47
-0
No files found.
app/service/course/v5/user.js
View file @
e72842a2
...
@@ -522,13 +522,14 @@ class UserService extends Service {
...
@@ -522,13 +522,14 @@ class UserService extends Service {
// app登录
// app登录
async
loginByApp
()
{
async
loginByApp
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
appUserId
=
ctx
.
cookies
.
get
(
'app_user_id'
,
{
signed
:
false
});
const
appUserId
=
ctx
.
cookies
.
get
(
'app_user_id'
,
{
signed
:
false
});
const
token
=
ctx
.
cookies
.
get
(
'token'
,
{
signed
:
false
});
const
token
=
ctx
.
cookies
.
get
(
'token'
,
{
signed
:
false
});
const
userId
=
ctx
.
cookies
.
get
(
'user_id'
,
{
signed
:
false
});
const
userId
=
ctx
.
cookies
.
get
(
'user_id'
,
{
signed
:
false
});
const
deviceId
=
ctx
.
cookies
.
get
(
'device_id'
,
{
signed
:
false
});
const
deviceId
=
ctx
.
cookies
.
get
(
'device_id'
,
{
signed
:
false
});
const
deviceLoginId
=
ctx
.
cookies
.
get
(
'device_login_id'
,
{
signed
:
false
});
const
deviceLoginId
=
ctx
.
cookies
.
get
(
'device_login_id'
,
{
signed
:
false
});
cons
t
params
=
{
le
t
params
=
{
app_user_id
:
appUserId
,
app_user_id
:
appUserId
,
token
,
token
,
uid
:
userId
,
uid
:
userId
,
...
@@ -536,6 +537,12 @@ class UserService extends Service {
...
@@ -536,6 +537,12 @@ class UserService extends Service {
device_login_id
:
deviceLoginId
,
device_login_id
:
deviceLoginId
,
};
};
if
(
ctx
.
isEmpty
(
token
))
{
const
jianbing_customer_id
=
ctx
.
cookies
.
get
(
'jianbing_customer_id'
,
{
signed
:
false
});
const
auth_token
=
ctx
.
cookies
.
get
(
'auth_token'
,
{
signed
:
false
});
params
=
await
this
.
service
.
user
.
goRegister
({
jianbing_customer_id
,
auth_token
});
}
const
result
=
await
ctx
.
helper
.
send_request
(
ctx
.
app
.
config
.
NODE_URL
+
'/user/auth'
,
params
,
{
const
result
=
await
ctx
.
helper
.
send_request
(
ctx
.
app
.
config
.
NODE_URL
+
'/user/auth'
,
params
,
{
method
:
'POST'
,
method
:
'POST'
,
});
});
...
...
app/service/user.js
View file @
e72842a2
...
@@ -41,6 +41,53 @@ class UserService extends Service {
...
@@ -41,6 +41,53 @@ class UserService extends Service {
return
ret
;
return
ret
;
}
}
async
goRegister
(
old_user_data
=
{})
{
// const { ctx } = this;
const
{
jianbing_customer_id
,
auth_token
}
=
old_user_data
;
if
(
!
jianbing_customer_id
||
!
auth_token
)
{
return
{};
}
const
phone_info
=
await
ctx
.
service
.
user
.
get_phone_by_user_sid
({
user_sid
:
jianbing_customer_id
,
token
:
auth_token
});
// 获取用户手机号码
const
phone
=
phone_info
.
phone
;
const
channel_alias
=
ctx
.
cookies
.
get
(
'channel_alias'
,
{
signed
:
false
});
let
app_channel_info
=
await
ctx
.
blockModel
.
AppChannel
.
one
({
where
:
{
alias
:
channel_alias
}
});
//
if
(
!
app_channel_info
||
!
app_channel_info
.
app_id
||
!
app_channel_info
.
channel_id
)
{
app_channel_info
=
await
ctx
.
blockModel
.
AppChannel
.
one
({
where
:
{
alias
:
'n_1_18100_appstore'
}
});
// 如果配置的渠道未渠道信息,使用默认的渠道,以防出错
}
const
app_id
=
app_channel_info
.
app_id
;
const
channel_id
=
app_channel_info
.
channel_id
;
const
go_register_params
=
{
phone
,
app_id
,
channel_id
,
};
const
result_go_register
=
await
ctx
.
helper
.
send_request
(
ctx
.
app
.
config
.
NODE_URL
+
'/login/go_register'
,
go_register_params
,
{
method
:
'POST'
});
// 通过手机号直接注册新用户中心
const
node_user_center_login_ret
=
result_go_register
.
data
;
ctx
.
logger
.
info
(
JSON
.
stringify
({
url
:
ctx
.
app
.
config
.
NODE_URL
+
'/login/go_register'
,
middleware_go_register_params
:
go_register_params
,
middleware_result_go_register
:
result_go_register
}));
if
(
!
node_user_center_login_ret
.
token
||
!
node_user_center_login_ret
.
uid
||
!
node_user_center_login_ret
.
app_user_id
)
{
return
{};
}
const
user_login_info
=
{
user_id
:
node_user_center_login_ret
.
uid
,
app_user_id
:
node_user_center_login_ret
.
app_user_id
,
token
:
node_user_center_login_ret
.
token
,
device_id
:
node_user_center_login_ret
.
device_id
,
device_login_id
:
node_user_center_login_ret
.
device_login_logs_id
,
};
const
expire
=
7200
*
1000
;
const
date
=
new
Date
();
for
(
const
key
in
user_login_info
)
{
const
value
=
user_login_info
[
key
];
const
exist_value
=
ctx
.
cookies
.
get
(
key
,
{
signed
:
false
});
if
(
!
exist_value
)
{
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
path
:
'/'
,
overwrite
:
true
});
}
}
return
user_login_info
;
}
}
}
module
.
exports
=
UserService
;
module
.
exports
=
UserService
;
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