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
69f1a82c
Commit
69f1a82c
authored
Dec 17, 2020
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: autologin
parent
934ace67
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
100 deletions
+88
-100
center-manage/app/base/service/impl/auth/authSve.js
+34
-37
center-manage/app/base/service/impl/common/channelhandlers/baidu.js
+1
-0
center-manage/app/base/service/impl/common/channelhandlers/zc360.js
+1
-0
center-manage/app/config/routes/api.js
+52
-63
No files found.
center-manage/app/base/service/impl/auth/authSve.js
View file @
69f1a82c
const
system
=
require
(
"../../../system"
);
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
class
AuthService
extends
ServiceBase
{
class
AuthService
extends
ServiceBase
{
constructor
(){
constructor
()
{
super
(
"auth"
,
ServiceBase
.
getDaoName
(
AuthService
));
super
(
"auth"
,
ServiceBase
.
getDaoName
(
AuthService
));
}
}
//字符串数组参数
//字符串数组参数
//前端角色查询,按照来源应用和来源公司查询
//前端角色查询,按照来源应用和来源公司查询
async
findAuthsByRole
(
roleids
,
appid
,
comid
)
{
async
findAuthsByRole
(
roleids
,
appid
,
comid
)
{
//{where:{id:{[this.db.Op.in]:ids}}}
//{where:{id:{[this.db.Op.in]:ids}}}
//var newattrs=rolecodestr.split(",");
//var newattrs=rolecodestr.split(",");
var
aths
=
await
this
.
dao
.
model
.
findAll
({
var
aths
=
await
this
.
dao
.
model
.
findAll
({
attributes
:[
"bizcode"
,
"authstrs"
,
"codepath"
],
attributes
:
[
"bizcode"
,
"authstrs"
,
"codepath"
],
where
:{
role_id
:{[
this
.
db
.
Op
.
in
]:
roleids
}}});
where
:
{
role_id
:
{
[
this
.
db
.
Op
.
in
]:
roleids
}
}
//因为是按照角色ID,所以不需要按照公司
});
// where:{role_id:{[this.db.Op.in]:roleids},app_id:appid,company_id:comid}});
//因为是按照角色ID,所以不需要按照公司
// where:{role_id:{[this.db.Op.in]:roleids},app_id:appid,company_id:comid}});
return
aths
;
return
aths
;
}
}
async
saveAuths
(
auths
,
appid
,
cmid
){
async
saveAuths
(
auths
,
appid
,
cmid
)
{
//先按照code 和 bizcode查询
//先按照code 和 bizcode查询
var
self
=
this
;
var
self
=
this
;
console
.
log
(
"yyyyyyyyyvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
);
return
self
.
db
.
transaction
(
async
function
(
t
)
{
console
.
log
(
auths
);
for
(
var
i
=
0
;
i
<
auths
.
length
;
i
++
)
{
return
self
.
db
.
transaction
(
async
function
(
t
){
var
tmpAuth
=
auths
[
i
];
for
(
var
i
=
0
;
i
<
auths
.
length
;
i
++
){
tmpAuth
.
app_id
=
appid
;
var
tmpAuth
=
auths
[
i
];
tmpAuth
.
company_id
=
cmid
;
tmpAuth
.
app_id
=
appid
;
var
objrtn
=
await
self
.
dao
.
model
.
findOrCreate
({
tmpAuth
.
company_id
=
cmid
;
defaults
:
tmpAuth
,
var
objrtn
=
await
self
.
dao
.
model
.
findOrCreate
({
where
:
{
role_id
:
tmpAuth
.
role_id
,
bizcode
:
tmpAuth
.
bizcode
},
//注意这里bizcode存储的是节点的code值
defaults
:
tmpAuth
,
transaction
:
t
,
where
:{
role_id
:
tmpAuth
.
role_id
,
bizcode
:
tmpAuth
.
bizcode
},
//注意这里bizcode存储的是节点的code值
});
transaction
:
t
,
if
(
!
objrtn
[
1
].
created
)
{
});
//就执行更新操作
console
.
log
(
"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
);
await
objrtn
[
0
].
update
(
tmpAuth
,
{
where
:
{
role_id
:
tmpAuth
.
role_id
,
bizcode
:
tmpAuth
.
bizcode
},
transaction
:
t
})
console
.
log
(
objrtn
);
}
if
(
!
objrtn
[
1
].
created
){
}
//就执行更新操作
var
aths
=
await
self
.
dao
.
model
.
findAll
({
where
:
{
role_id
:
tmpAuth
.
role_id
,
app_id
:
tmpAuth
.
app_id
},
transaction
:
t
});
await
objrtn
[
0
].
update
(
tmpAuth
,{
where
:{
role_id
:
tmpAuth
.
role_id
,
bizcode
:
tmpAuth
.
bizcode
},
transaction
:
t
})
return
aths
;
}
});
}
var
aths
=
await
self
.
dao
.
model
.
findAll
({
where
:{
role_id
:
tmpAuth
.
role_id
,
app_id
:
tmpAuth
.
app_id
},
transaction
:
t
});
return
aths
;
});
}
}
}
}
module
.
exports
=
AuthService
;
module
.
exports
=
AuthService
;
center-manage/app/base/service/impl/common/channelhandlers/baidu.js
View file @
69f1a82c
...
@@ -170,6 +170,7 @@ class BaiduHandler {
...
@@ -170,6 +170,7 @@ class BaiduHandler {
obj
.
servicerCode
=
resInfo
.
company_id
;
obj
.
servicerCode
=
resInfo
.
company_id
;
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
obj
.
salesmanOpcode
=
`root10/bizgroup01/g1members/
${
datajson
.
actionBody
.
needsolution
.
salesmanInfo
.
salesmanChannelId
}
`
;
console
.
log
(
"salesmanChannelId: "
+
datajson
.
actionBody
.
needsolution
.
salesmanInfo
.
salesmanChannelId
+
"获取业务员opcode失败:"
+
error
)
console
.
log
(
"salesmanChannelId: "
+
datajson
.
actionBody
.
needsolution
.
salesmanInfo
.
salesmanChannelId
+
"获取业务员opcode失败:"
+
error
)
}
}
}
}
...
...
center-manage/app/base/service/impl/common/channelhandlers/zc360.js
View file @
69f1a82c
...
@@ -47,6 +47,7 @@ class Zc360Handler {
...
@@ -47,6 +47,7 @@ class Zc360Handler {
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"salesmanId: "
+
datajson
.
actionBody
.
needsolution
.
salesmanInfo
.
salesmanId
+
"获取业务员opcode失败:"
+
error
)
console
.
log
(
"salesmanId: "
+
datajson
.
actionBody
.
needsolution
.
salesmanInfo
.
salesmanId
+
"获取业务员opcode失败:"
+
error
)
obj
.
salesmanOpcode
=
`root10/bizgroup01/g1members/
${
datajson
.
actionBody
.
needsolution
.
salesmanInfo
.
salesmanId
}
`
;
}
}
}
}
...
...
center-manage/app/config/routes/api.js
View file @
69f1a82c
...
@@ -9,79 +9,70 @@ let channelCache = {};
...
@@ -9,79 +9,70 @@ let channelCache = {};
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
app
.
post
(
"/autologin"
,
async
function
(
req
,
res
,
next
)
{
app
.
post
(
"/autologin"
,
async
function
(
req
,
res
,
next
)
{
try
{
try
{
console
.
log
(
req
.
body
)
console
.
log
(
'---- 免登 -----'
);
let
appkey
=
req
.
body
.
appkey
.
trim
()
console
.
log
(
req
.
body
);
let
appkey
=
req
.
body
.
appkey
.
trim
();
if
(
!
appkey
)
{
if
(
!
appkey
)
{
let
rd
=
System
.
getResult
(
null
,
"没有资质宝appkey,请联系资质宝服务提供方"
)
res
.
json
(
System
.
getResult
(
null
,
"没有资质宝appkey,请联系资质宝服务提供方"
));
res
.
end
(
JSON
.
stringify
(
rd
))
return
return
}
}
let
companykey
=
req
.
body
.
companykey
.
trim
()
let
companykey
=
req
.
body
.
companykey
.
trim
()
;
if
(
!
companykey
)
{
if
(
!
companykey
)
{
let
rd
=
System
.
getResult
(
null
,
"没有公司宝的租户companykey,请联系资质宝服务提供方"
)
res
.
json
(
System
.
getResult
(
null
,
"没有公司宝的租户companykey,请联系资质宝服务提供方"
));
res
.
end
(
JSON
.
stringify
(
rd
))
return
return
}
}
//let cooktoken = req.cookies["accessToken"]
let
cooktoken
=
req
.
body
.
accesskey
let
cooktoken
=
req
.
body
.
accesskey
console
.
log
(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>........................................"
)
let
tv
=
cooktoken
||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImUxNzAzYzIwMDFkZDExZTliNTBmZDUyNWJjMmE3ZTFkIn0.eyJpZCI6IjVjOTM2Yjk1ODU4MGJjNGUwOGUwODQzZSIsIm5hbWUiOiLlvKDlm73np4AiLCJlbXBsb3llZSI6IjVjOTM2YmJhYzY4ZWIxMjMwOGQxMjEzOSIsInBob25lIjoickdGR1ZwZHFiOGNPMUNYeC9VOEVYQT09Iiwib3JnaWQiOiI1YmNmZTk1Y2IwYTAxZjAwMDkyODRiYzMiLCJyb2xlcyI6WyLlkZjlt6UiLCJpZHV0eeeuoeeQhuWRmCIsIuS-m-W6lOWVhuS6pOS7mCIsIui1hOi0qOWuneS6pOS7mOWRmCJdLCJwbGF0Zm9ybSI6ImQzOTViZGFkNmI2MGY0ODQ5MTEwNDA4OWNhYjU5OGI3IiwidW5pb25pZCI6IiIsImp0aSI6Im9vMGZHR1YwZUVaOWdxbTEiLCJleHAiOjE2MDg1OTkwMjQsImlhdCI6MTYwNzk5NDIyNH0.Q3QmHoUpcX14VucsivDNHfx3DYbAI6B59i0Ohb31Vmmfw1F-kI-IV8ZTvzBi-PKY3G-ZH7FS94BHvM2KOEVKdSnTLzhd-A-LzRI6xaWFDCYdGbjMJAYtmNqzD_xZZyx4diBPHxBJLeSyb_3uMi9doMH7Ef56DgJ05UC6Ip5J1KtIRUszMNR6--PnwwsZxLeBlObaJAGkEjKBQBZUvbVlpm1yleT5t4EKcVG9EMyibYnRq2MVK273tnqb8nb2NTeyVB9nRctzSzmFwCkChYbm-z4JvSjp8PEh50FL9eVqADbpUm3lbXahYKFxmQBfxMxm8ur6fgeU7y_vRXFzL3WNFw'
console
.
log
(
cooktoken
)
let
sourceUser
=
System
.
verify
(
tv
,
settings
.
publickey
());
let
tv
=
cooktoken
console
.
log
(
'--- 解析用户信息 -----'
);
let
sourceUser
=
System
.
verify
(
tv
,
settings
.
publickey
())
console
.
log
(
sourceUser
);
let
openid
=
sourceUser
.
employee
;
// { id: '5f8faf05787b88000a2e178b',
let
userName
=
openid
;
// name: '张华',
let
nickName
=
sourceUser
.
name
;
// employee: '5f8faf05787b88000a2e178c',
let
fixedcodes
=
[
"资质宝交付员"
,
'资质宝业务员'
,
"工商业务员"
,
"工商交付员"
];
// phone: 'd1htypf8Sme3fvcXP20R+w==',
let
rolecodes
=
sourceUser
.
roles
?
sourceUser
.
roles
:
[];
// orgid: '5bcfe95cb0a01f0009284bc3',
// roles: [ '员工', '资质宝业务员', '资质宝交付员' ],
// platform: '8cdf558c8645c7031f164dc23a55a28f',
// unionid: '',
// jti: 'gaBQQKKO6ZLNXNfA',
// exp: 1605083401,
// iat: 1604478601
// }
/**
* TODO:
* 1. 建立 磐农角色
* 2. 建立组织结构 获取 磐农组织结构路径
* 3. 获取角色id 设置
*/
let
openid
=
sourceUser
.
employee
let
userName
=
openid
let
nickName
=
sourceUser
.
name
let
unid
=
sourceUser
.
unionid
let
fixedcodes
=
[
"资质宝交付员"
,
'资质宝业务员'
]
let
rolecodes
=
sourceUser
.
roles
?
sourceUser
.
roles
:
[]
let
rcs
=
rolecodes
.
filter
(
rc
=>
{
let
rcs
=
rolecodes
.
filter
(
rc
=>
{
if
(
fixedcodes
.
indexOf
(
rc
)
>=
0
)
{
if
(
fixedcodes
.
indexOf
(
rc
)
>=
0
)
{
return
true
return
true
;
}
else
{
}
else
{
return
false
return
false
;
}
}
})
});
if
(
rcs
.
length
==
0
)
{
if
(
rcs
.
length
===
0
)
{
let
rd
=
System
.
getResult
(
null
,
"当前登录人没有资质宝访问权限"
)
res
.
json
(
System
.
getResult
(
null
,
"当前登录人没有资质宝访问权限"
));
res
.
end
(
JSON
.
stringify
(
rd
))
return
return
}
}
//先按照openid去查看是否已经存在
//先按照openid去查看是否已经存在
let
uf
=
await
userS
.
dao
.
model
.
findOne
({
where
:
{
openid
:
openid
}
})
let
uf
=
await
userS
.
dao
.
model
.
findOne
({
where
:
{
openid
:
openid
}
})
;
if
(
!
uf
)
{
if
(
!
uf
)
{
//按照公司companykey查询出要注册公司的所在公司,取公司id
//按照公司companykey查询出要注册公司的所在公司,取公司id
let
company
=
await
companyS
.
dao
.
model
.
findOne
({
where
:
{
companykey
:
companykey
}
})
let
company
=
await
companyS
.
dao
.
model
.
findOne
({
where
:
{
companykey
:
companykey
}
})
;
//构造注册用户对象,需要设置默认角色,默认角色需要按照rolecode查询出角色
//构造注册用户对象,需要设置默认角色,默认角色需要按照rolecode查询出角色
let
rolesfind
=
await
roleS
.
dao
.
model
.
findAll
({
where
:
{
code
:
{
[
roleS
.
db
.
Op
.
in
]:
rcs
},
company_id
:
company
.
id
}
})
let
rolesfind
=
await
roleS
.
dao
.
model
.
findAll
({
where
:
{
code
:
{
[
roleS
.
db
.
Op
.
in
]:
rcs
},
company_id
:
company
.
id
}
})
;
//根据rolecode--,设置组织路径
//根据rolecode--,设置组织路径
let
opath
=
''
let
opath
=
''
;
let
isSalesman
=
false
let
isSalesman
=
false
;
let
isDelivery
=
false
let
isDelivery
=
false
;
if
(
rcs
[
0
]
==
"资质宝业务员"
)
{
let
skilltags
=
new
Set
();
opath
=
"root10/bizgroup01/g1members/"
+
userName
if
(
rcs
.
includes
(
"资质宝交付员"
))
{
isSalesman
=
true
isDelivery
=
true
;
}
else
{
opath
=
"root10/dlivergroup/dgroupmembers/"
+
userName
;
opath
=
"root10/dlivergroup/dgroupmembers/"
+
userName
skilltags
.
add
(
"icp,edi"
);
isDelivery
=
true
}
if
(
rcs
.
includes
(
"工商交付员"
))
{
isDelivery
=
true
;
opath
=
"root10/dlivergroup/dgroupmembers/"
+
userName
;
skilltags
.
add
(
"公司注册"
);
}
if
(
rcs
.
includes
(
"资质宝业务员"
))
{
isSalesman
=
true
;
opath
=
"root10/bizgroup01/g1members/"
+
userName
;
skilltags
.
add
(
"icp,edi"
);
}
if
(
rcs
.
includes
(
"工商业务员"
))
{
isSalesman
=
true
;
opath
=
"root10/bizgroup01/g1members/"
+
userName
;
skilltags
.
add
(
"公司注册"
);
}
}
//调用pmregister
//调用pmregister
let
reguser
=
{
let
reguser
=
{
...
@@ -94,16 +85,14 @@ module.exports = function (app) {
...
@@ -94,16 +85,14 @@ module.exports = function (app) {
isSalesman
:
isSalesman
,
isSalesman
:
isSalesman
,
isDelivery
:
isDelivery
,
isDelivery
:
isDelivery
,
isAllocated
:
true
,
isAllocated
:
true
,
skilltags
:
'icp,edi'
skilltags
:
[...
skilltags
].
join
()
}
}
uf
=
await
userS
.
registerByTantent
(
reguser
)
uf
=
await
userS
.
registerByTantent
(
reguser
)
}
}
let
rtnobj
=
await
userS
.
loginApp
(
appkey
,
userName
)
let
rtnobj
=
await
userS
.
loginApp
(
appkey
,
userName
);
let
rtntmp
=
System
.
getResult
({
openurl
:
rtnobj
.
homePage
+
"?code="
+
rtnobj
.
code
})
res
.
json
(
System
.
getResult
({
openurl
:
rtnobj
.
homePage
+
"?code="
+
rtnobj
.
code
}))
let
rtn
=
JSON
.
stringify
(
rtntmp
)
res
.
end
(
rtn
)
}
catch
(
e
)
{
}
catch
(
e
)
{
res
.
end
(
JSON
.
stringify
(
System
.
getResult
(
null
,
e
.
message
)))
res
.
json
(
System
.
getResult
(
null
,
e
.
message
));
}
}
})
})
app
.
post
(
"/entService/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
post
(
"/entService/*"
,
async
function
(
req
,
res
,
next
)
{
...
@@ -151,7 +140,7 @@ module.exports = function (app) {
...
@@ -151,7 +140,7 @@ module.exports = function (app) {
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
console
.
log
(
e
)
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
e
})
);
res
.
json
({
status
:
-
1
,
message
:
e
}
);
}
}
})
})
app
.
get
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
get
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
...
...
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