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
61bda907
Commit
61bda907
authored
May 11, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feishu login
parent
84a73e50
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
33 deletions
+33
-33
center-channel/app/base/service/impl/common/feishuLoginSve.js
+18
-29
center-channel/app/base/service/impl/utilsSve/utilsFeishuSve.js
+1
-1
center-channel/app/base/utils/execClient.js
+13
-2
center-channel/app/config/routes/api.js
+1
-1
No files found.
center-channel/app/base/service/impl/common/feishuLoginSve.js
View file @
61bda907
...
@@ -8,7 +8,8 @@ class feishuLoginService{
...
@@ -8,7 +8,8 @@ class feishuLoginService{
};
};
//用户登录
//用户登录
async
checkAndLogin
(
pobj
){
async
checkAndLogin
(
pobj
){
return
system
.
getResultSuccess
(
null
,
"测试"
);
// return system.getResultSuccess(null,"测试");
try
{
if
(
!
pobj
.
code
){
if
(
!
pobj
.
code
){
return
system
.
getResultFail
(
-
100
,
"code参数不能为空"
);
return
system
.
getResultFail
(
-
100
,
"code参数不能为空"
);
}
}
...
@@ -34,41 +35,29 @@ class feishuLoginService{
...
@@ -34,41 +35,29 @@ class feishuLoginService{
var
loginByUserNameParams
=
{
var
loginByUserNameParams
=
{
"actionType"
:
"getLoginByUserName"
,
"actionType"
:
"getLoginByUserName"
,
"actionBody"
:
{
"actionBody"
:
{
"open_id"
:
userAccessTokenObj
.
open_id
"open_id"
:
userAccessTokenObj
.
open_id
,
"channelUserId"
:
userAccessTokenObj
.
open_id
,
// Y 渠道用户ID
"channelUserName"
:
userAccessTokenObj
.
name
,
// N 渠道用户名
"nickName"
:
userAccessTokenObj
.
name
,
// N 用户昵称
"head_url"
:
userAccessTokenObj
.
avatar_url
//头像
}
}
};
};
var
loginByUserNameRes
=
await
this
.
getLoginByUserName
(
loginByUserNameParams
);
var
loginByUserNameRes
=
await
this
.
getLoginByUserName
(
loginByUserNameParams
);
if
(
loginByUserNameRes
&&
loginByUserNameRes
.
status
==
0
){
if
(
loginByUserNameRes
&&
loginByUserNameRes
.
status
==
0
){
return
loginByUserNameRes
;
//获取userpin直接返回
return
loginByUserNameRes
;
//获取userpin直接返回
}
}
// // 获取飞书用户信息
// var userInfoParams={
// user_access_token:userAccessTokenObj.access_token
// };
// var userInfoRes = await this.utilsFeishuSve.getUserInfo(userInfoParams);
// if(userInfoRes.status!=0){
// return userInfoRes;
// }
// var userInfoObj = userInfoRes.data;
//获取飞书用户信息
}
catch
(
e
)
{
var
userInfoParams
=
{
return
system
.
getResultFail
(
-
200
,
e
.
stack
);
user_access_token
:
userAccessTokenObj
.
access_token
};
var
userInfoRes
=
await
this
.
utilsFeishuSve
.
getUserInfo
(
userInfoParams
);
if
(
userInfoRes
.
status
!=
0
){
return
userInfoRes
;
}
var
userInfoObj
=
userInfoRes
.
data
;
var
createUserParams
=
{
// uapp_id,channel_userid,channel_username,channel_nickname,open_id,he
};
loginByUserNameParams
=
{
"actionType"
:
"getLoginByUserName"
,
"actionBody"
:
{
"open_id"
:
userAccessTokenObj
.
open_id
,
"channelUserId"
:
userInfoObj
.
mobile
,
// Y 渠道用户ID
"channelUserName"
:
userInfoObj
.
name
,
// N 渠道用户名
"mobile"
:
userInfoObj
.
mobile
,
// N 渠道用户手机号
"nickName"
:
userInfoObj
.
name
,
// N 用户昵称
"email"
:
userInfoObj
.
eamil
,
//邮箱
"head_url"
:
userInfoObj
.
avatar_url
//头像
}
};
loginByUserNameRes
=
await
this
.
getLoginByUserName
(
loginByUserNameParams
);
if
(
loginByUserNameRes
&&
loginByUserNameRes
.
status
==
0
){
return
loginByUserNameRes
;
//获取userpin直接返回
}
}
return
system
.
getResultFail
(
"获取userpin失败"
);
return
system
.
getResultFail
(
"获取userpin失败"
);
}
}
...
...
center-channel/app/base/service/impl/utilsSve/utilsFeishuSve.js
View file @
61bda907
...
@@ -148,7 +148,7 @@ class UtilsFeishuService{
...
@@ -148,7 +148,7 @@ class UtilsFeishuService{
var
obj
=
{
var
obj
=
{
user_access_token
:
pobj
.
user_access_token
user_access_token
:
pobj
.
user_access_token
};
};
var
rtn
=
await
this
.
execClient
.
execGet
(
obj
,
url
);
var
rtn
=
await
this
.
execClient
.
exec
Feishu
Get
(
obj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
}
...
...
center-channel/app/base/utils/execClient.js
View file @
61bda907
...
@@ -7,7 +7,7 @@ class ExecClient {
...
@@ -7,7 +7,7 @@ class ExecClient {
this
.
cmdPostPattern
=
"curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"
;
this
.
cmdPostPattern
=
"curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"
;
this
.
cmdGetPattern
=
"curl -G -X GET '{url}'"
;
this
.
cmdGetPattern
=
"curl -G -X GET '{url}'"
;
this
.
cmdPushDataPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}"
;
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} "
;
}
}
getUUID
()
{
getUUID
()
{
var
uuid
=
uuidv4
();
var
uuid
=
uuidv4
();
...
@@ -63,7 +63,18 @@ class ExecClient {
...
@@ -63,7 +63,18 @@ class ExecClient {
console
.
log
(
cmd
);
console
.
log
(
cmd
);
return
cmd
;
return
cmd
;
}
}
FetchFeishuGetCmd
(
subData
,
url
)
{
var
cmd
=
this
.
cmdFeishuGetPattern
.
replace
(
/
\{
data
\}
/g
,
subData
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
Authorization
\}
/g
,
"Bearer "
+
subData
.
user_access_token
);
console
.
log
(
cmd
);
return
cmd
;
}
async
execFeishuGet
(
subData
,
url
)
{
let
cmd
=
this
.
FetchFeishuGetCmd
(
subData
,
url
);
console
.
log
(
cmd
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
async
execGet
(
subData
,
url
)
{
async
execGet
(
subData
,
url
)
{
let
cmd
=
this
.
FetchGetCmd
(
subData
,
url
);
let
cmd
=
this
.
FetchGetCmd
(
subData
,
url
);
console
.
log
(
cmd
);
console
.
log
(
cmd
);
...
...
center-channel/app/config/routes/api.js
View file @
61bda907
...
@@ -353,7 +353,7 @@ module.exports = function (app) {
...
@@ -353,7 +353,7 @@ module.exports = function (app) {
try
{
try
{
// console.log(req,"/feishu/login++++++++++++++++++++++++++++++++++++++");
// console.log(req,"/feishu/login++++++++++++++++++++++++++++++++++++++");
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
feishuLoginSve
.
checkAndLogin
(
req
.
bod
y
);
var
result
=
await
feishuLoginSve
.
checkAndLogin
(
req
.
quer
y
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=login"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
...
...
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