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
c67c70a5
Commit
c67c70a5
authored
Jul 07, 2023
by
董加伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
信狐-授信贷联登
parent
7659fa6b
Pipeline
#48948
passed with stage
in 3 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
5 deletions
+104
-5
response.js
app/controller/response.js
+54
-0
helper.js
app/extend/helper.js
+32
-0
response.js
app/router/response.js
+1
-0
config.local.js
config/config.local.js
+17
-5
No files found.
app/controller/response.js
View file @
c67c70a5
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
const
urlib
=
require
(
'url'
);
const
moment
=
require
(
'moment'
);
class
ResponseController
extends
Controller
{
...
...
@@ -167,6 +169,58 @@ class ResponseController extends Controller {
ctx
.
success
(
token
);
}
async
internalAuthByXinhu
()
{
const
{
ctx
,
app
}
=
this
;
const
input_params
=
ctx
.
query
;
const
rule
=
{
target_url
:
{
type
:
'string'
,
required
:
true
},
channel_id
:
{
type
:
'string'
,
required
:
true
},
user_sid
:
{
type
:
'string'
,
required
:
false
},
user_token
:
{
type
:
'string'
,
required
:
false
},
};
ctx
.
validate
(
rule
,
input_params
);
if
(
input_params
.
user_token
)
{
const
user_token
=
await
app
.
memcache
.
get
(
`
${
app
.
name
}
/
${
app
.
config
.
env
}
/
${
input_params
.
user_sid
}
`
);
if
(
user_token
!==
input_params
.
user_token
)
ctx
.
failed
(
'user_token 已失效'
);
// token回收
await
app
.
memcache
.
set
(
`
${
app
.
name
}
/
${
app
.
config
.
env
}
/
${
input_params
.
user_sid
}
`
,
''
,
60
);
}
const
channel_alias
=
input_params
.
channel_id
;
const
skip_url
=
new
urlib
.
URL
(
input_params
.
target_url
);
skip_url
.
searchParams
.
append
(
'channel_id'
,
channel_alias
);
const
target_url
=
skip_url
.
toString
();
const
user_sid
=
ctx
.
helper
.
encodeUserSidNew
(
input_params
.
user_sid
);
const
auth_token
=
await
ctx
.
helper
.
md5
(
String
(
user_sid
)
+
moment
().
format
(
'MDYYYY'
)
+
'f74jkdsy83sjf'
,
'utf8'
);
const
phone_info
=
await
ctx
.
service
.
user
.
get_phone_by_user_sid
({
user_sid
,
token
:
auth_token
});
// 获取用户手机号码
ctx
.
logger
.
info
(
'phone_info: '
+
JSON
.
stringify
(
phone_info
));
const
phone
=
phone_info
.
phone
;
const
app_channel_info
=
await
ctx
.
blockModel
.
AppChannel
.
one
({
where
:
{
alias
:
channel_alias
}
});
//
ctx
.
logger
.
info
(
'app_channel_info: '
+
JSON
.
stringify
(
app_channel_info
));
const
channel_id
=
(
app_channel_info
&&
app_channel_info
.
channel_id
)
?
app_channel_info
.
channel_id
:
false
;
const
app_id
=
(
app_channel_info
&&
app_channel_info
.
app_id
)
?
app_channel_info
.
app_id
:
false
;
let
node_user_center_login_ret
=
{};
const
go_register_params
=
{
phone
,
app_id
,
channel_id
};
ctx
.
logger
.
info
(
'go_register_params: '
+
JSON
.
stringify
(
go_register_params
));
const
result_go_register
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_URL
+
'/login/go_register'
,
go_register_params
,
{
method
:
'POST'
});
// 通过手机号直接注册新用户中心
node_user_center_login_ret
=
result_go_register
.
data
;
node_user_center_login_ret
.
user_id
=
node_user_center_login_ret
.
uid
;
node_user_center_login_ret
.
device_login_id
=
node_user_center_login_ret
.
device_login_logs_id
;
delete
(
node_user_center_login_ret
.
uid
);
delete
(
node_user_center_login_ret
.
device_login_logs_id
);
node_user_center_login_ret
.
jianbing_customer_id
=
user_sid
;
node_user_center_login_ret
.
auth_token
=
auth_token
;
for
(
const
key
in
node_user_center_login_ret
)
{
const
value
=
node_user_center_login_ret
[
key
];
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
path
:
'/'
,
overwrite
:
true
});
}
console
.
log
(
11111111
,
target_url
);
ctx
.
redirect
(
target_url
);
}
}
module
.
exports
=
ResponseController
;
app/extend/helper.js
View file @
c67c70a5
...
...
@@ -524,6 +524,38 @@ module.exports = {
return
rtn
;
},
encodeUserSidNew
(
userId
)
{
const
rand
=
'OU1WjLvZCrRJ7Yo0gE2XDjuuaSAUuaH1bhHPuMymcdfEeKz0igRhXQkMuLTm1'
;
const
randKey
=
2019
;
let
rtn
=
''
;
const
code
=
userId
<<
2
;
const
randLength
=
11
;
const
len
=
String
(
code
).
length
;
const
codeLen
=
rand
.
slice
(
0
,
randLength
);
const
codeNums
=
rand
.
slice
(
randLength
,
randLength
+
12
);
const
codeExt
=
rand
.
slice
(
randLength
+
12
,
rand
.
length
);
const
begin
=
codeLen
.
slice
(
len
-
1
,
len
);
const
ext
=
randLength
-
len
-
1
;
let
temp
=
String
(
Math
.
floor
(
code
/
randKey
)).
replace
(
'.'
,
''
);
temp
=
temp
.
slice
(
-
ext
);
const
arrExtTemp
=
codeExt
.
split
(
''
);
const
arrExt
=
temp
.
split
(
''
);
for
(
const
v
of
arrExt
)
{
rtn
+=
arrExtTemp
[
v
];
}
const
arrNumsTemp
=
codeNums
.
split
(
''
);
const
arrNums
=
String
(
code
).
split
(
''
);
for
(
const
v
of
arrNums
)
{
rtn
+=
arrNumsTemp
[
v
];
}
rtn
=
String
(
userId
).
slice
(
0
,
5
)
+
begin
+
rtn
;
return
rtn
;
},
// aes加密
async
cipherByAES
(
data
)
{
const
{
ctx
}
=
this
;
...
...
app/router/response.js
View file @
c67c70a5
...
...
@@ -4,6 +4,7 @@ module.exports = app => {
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/response'
);
router
.
get
(
'avoid_auth'
,
'/internal/auth'
,
'response.internalAuth'
);
// 购房计划地图点位
router
.
get
(
'avoid_auth'
,
'/internal/auth-xinhu'
,
'response.internalAuthByXinhu'
);
// 信狐-授信贷授权登录
router
.
get
(
'third'
,
'/internal/token'
,
'response.token'
);
router
.
post
(
'avoid_auth'
,
'/internal/token'
,
'response.token'
);
...
...
config/config.local.js
View file @
c67c70a5
...
...
@@ -64,6 +64,18 @@ module.exports = appInfo => {
port
:
3306
,
},
{
// 公积金数据库
timezone
:
'+08:00'
,
delegate
:
'gjjModel'
,
baseDir
:
'model/gjj'
,
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'uatgjj'
,
username
:
'uatgjj'
,
password
:
'jianbingUATsljwd'
,
port
:
3306
,
},
{
// 东八时区
timezone
:
'+08:00'
,
delegate
:
'realestateModel'
,
...
...
@@ -71,7 +83,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'realestate_
dev
'
,
database
:
'realestate_
uat
'
,
username
:
'realestate'
,
password
:
'ppD1sDSutHG83T2s1Ue3k'
,
port
:
3306
,
...
...
@@ -84,9 +96,9 @@ module.exports = appInfo => {
// other sequelize configurations
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'
dev
huodong'
,
username
:
'
dev
huodong'
,
password
:
'jianbing
2014GG
'
,
database
:
'
uat
huodong'
,
username
:
'
uat
huodong'
,
password
:
'jianbing
UATsljwd2016
'
,
port
:
3306
,
},
{
...
...
@@ -97,7 +109,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'prometheus_
dev
'
,
database
:
'prometheus_
uat
'
,
username
:
'prometheus'
,
password
:
'q9t8Ay4qIUW4sw3s25K28'
,
port
:
3306
,
...
...
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