Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
caa84b87
Commit
caa84b87
authored
Oct 22, 2020
by
任晓松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
b1b694de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
30 deletions
+53
-30
center-channel/app/base/service/impl/utilsSve/utilsAuthSve.js
+20
-21
center-channel/app/base/utils/execClient.js
+13
-8
center-channel/app/base/utils/restClient.js
+6
-1
center-channel/app/config/settings.js
+14
-0
No files found.
center-channel/app/base/service/impl/utilsSve/utilsAuthSve.js
View file @
caa84b87
...
...
@@ -167,30 +167,20 @@ class UtilsAuthService extends AppServiceBase {
* @returns {Promise<void>}
*/
async
channelUserLogin
(
pobj
,
actionBody
,
req
){
//360登录地址
let
skipUrl
=
''
;
let
opResult
=
system
.
getResult
(
null
,
"req Failure"
);
//----通过Authorization 获取用户信息
let
Authorization
=
req
.
headers
[
"authorization"
]
||
""
;
if
(
!
Authorization
){
opResult
.
data
.
redirectUrl
=
skipUrl
;
opResult
=
system
.
getResultFail
(
-
99
,
'用户未登录'
,{
redirectUrl
:
'skipUrl'
});
return
opResult
;
}
let
icCompanyUrl
=
''
;
let
subData
=
{
Authorization
:
Authorization
}
let
rtn
=
await
this
.
execClient
.
execFqGet
(
subData
,
icCompanyUrl
);
let
opResult
=
system
.
getResultSuccess
()
let
pin
=
actionBody
.
pin
;
let
result
=
await
this
.
get360Token
();
let
token
=
result
.
access_token
;
//360验证接口
let
subData
=
"pin="
+
pin
+
"&token="
+
token
let
rtn
=
await
this
.
restClient
.
execGet
(
subData
,
settings
.
requestUrl360
());
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"
exec
Post data is empty"
);
return
system
.
getResult
(
null
,
"
rest
Post data is empty"
);
}
var
userInfo
=
JSON
.
parse
(
rtn
.
stdout
);
//----结束
let
checkRet
=
JSON
.
parse
(
rtn
.
stdout
);
console
.
log
(
checkRet
,
'checkRet--------------'
)
//---渠道用户登录,有则返回userpin ,没有则注册用户并返回userpin
let
channelUserId
=
userInfo
.
mobile
;
actionBody
.
channelUserId
=
channelUserId
;
actionBody
.
channelUserId
=
pin
;
let
loginRt
=
await
this
.
getLoginByUserName
(
pobj
,
actionBody
);
if
(
loginRt
.
status
!=
0
&&
loginRt
.
status
!=
2060
)
{
return
loginRt
;
...
...
@@ -203,5 +193,14 @@ class UtilsAuthService extends AppServiceBase {
return
opResult
;
}
async
get360Token
(){
let
rtn
=
await
this
.
execClient
.
exec360GetToken
(
settings
.
tokenUrl360
())
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost data is empty"
);
}
let
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
}
module
.
exports
=
UtilsAuthService
;
center-channel/app/base/utils/execClient.js
View file @
caa84b87
...
...
@@ -2,6 +2,7 @@ var childproc = require('child_process');
const
util
=
require
(
'util'
);
const
exec
=
util
.
promisify
(
require
(
'child_process'
).
exec
);
const
uuidv4
=
require
(
'uuid/v4'
);
var
settings
=
require
(
"../../config/settings"
);
class
ExecClient
{
constructor
()
{
this
.
cmdPostPattern
=
"curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"
;
...
...
@@ -9,7 +10,8 @@ class ExecClient {
this
.
cmdPushDataPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}"
;
this
.
cmdFeishuGetPattern
=
"curl -X GET -k -H 'Content-Type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url} "
;
this
.
cmdFeishuPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
//360
this
.
cmd360PostPattern
=
"curl -u gongsibao:qPa4PsVsxbQ847i5pOKSmfPKrzRoNKqx -d '{data}' -X POST {url}"
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -80,11 +82,6 @@ class ExecClient {
console
.
log
(
cmd
);
return
cmd
;
}
FetchFqGetCmd
(
subData
,
url
)
{
var
cmd
=
this
.
cmdFeishuGetPattern
.
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
Authorization
\}
/g
,
"Bearer "
+
subData
.
Authorization
);
console
.
log
(
cmd
);
return
cmd
;
}
//飞书小程序GET请求
FetchFeishuGetCmd
(
subData
,
url
)
{
...
...
@@ -106,8 +103,16 @@ class ExecClient {
return
result
;
}
async
execFqGet
(
subData
,
url
)
{
let
cmd
=
this
.
FetchFqGetCmd
(
subData
,
url
);
Fetch360PostCmd
(
subData
,
url
){
var
cmd
=
this
.
cmd360PostPattern
.
replace
(
/
\{
data
\}
/g
,
subData
).
replace
(
/
\{
url
\}
/g
,
url
);
console
.
log
(
cmd
);
return
cmd
;
}
async
exec360GetToken
(
url
){
let
obj
=
{
"scope"
:
"smart_business"
,
"grant_type"
:
"client_credentials"
}
let
cmd
=
this
.
Fetch360PostCmd
(
qs
.
stringify
(
obj
),
url
);
console
.
log
(
cmd
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
...
...
center-channel/app/base/utils/restClient.js
View file @
caa84b87
...
...
@@ -19,7 +19,6 @@ class RestClient {
this
.
cmdPostPattern5
=
"curl -k --data '{data}' {url}"
;
// authorization=[token]
this
.
cmdPostpatternToken
=
"curl -k -H 'Content-type: application/json' -H 'authorization:{token}' -X POST {url}"
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -172,6 +171,12 @@ class RestClient {
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
async
execDeliveryPost
(
subdata
,
url
){
let
cmd
=
this
.
FetchPostCmd
(
subdata
,
url
)
cmd
+=
" -H 'XAPPKEY:647a68c9-da01-40d3-9763-1ffa0f64cf3f'"
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
test
()
{
console
.
log
(
"hello"
);
}
...
...
center-channel/app/config/settings.js
View file @
caa84b87
...
...
@@ -228,6 +228,20 @@ var settings = {
return
"https://m.ucommune.com/"
// 6.29lin修改为测试环境。原因优客 目前还没有正式环境
}
},
tokenUrl360
:
function
(){
if
(
this
.
env
==
"dev"
)
{
return
"https://oauth2.e.360.cn/site/token"
// 360测试环境
}
else
{
return
""
//
}
},
requestUrl360
:
function
(){
if
(
this
.
env
==
"dev"
)
{
return
"http://180.163.239.98:38085/"
// 360测试环境
}
else
{
return
""
//
}
},
aliUappId
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
18
// uapp_id
...
...
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