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
a704a5a4
Commit
a704a5a4
authored
Jan 28, 2021
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 兼容新云服自动登录
parent
24064c27
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
center-manage/app/config/routes/api.js
+78
-0
No files found.
center-manage/app/config/routes/api.js
View file @
a704a5a4
...
@@ -95,6 +95,84 @@ module.exports = function (app) {
...
@@ -95,6 +95,84 @@ module.exports = function (app) {
res
.
json
(
System
.
getResult
(
null
,
e
.
message
));
res
.
json
(
System
.
getResult
(
null
,
e
.
message
));
}
}
})
})
app
.
post
(
"/autologinV1"
,
async
function
(
req
,
res
,
next
)
{
try
{
console
.
log
(
'---- 免登 -----'
);
console
.
log
(
req
.
body
);
let
sourceUser
=
req
.
body
.
userInfo
;
if
(
!
sourceUser
.
employee
||
!
sourceUser
.
name
||
!
sourceUser
.
roles
)
{
res
.
json
(
System
.
getResult
(
null
,
"参数有误,请联系技术人员"
));
}
console
.
log
(
sourceUser
);
let
openid
=
sourceUser
.
employee
;
let
userName
=
openid
;
let
nickName
=
sourceUser
.
name
;
let
fixedcodes
=
[
"资质宝交付员"
,
'资质宝业务员'
,
"工商业务员"
,
"工商交付员"
];
let
rolecodes
=
sourceUser
.
roles
?
sourceUser
.
roles
:
[];
let
rcs
=
rolecodes
.
filter
(
rc
=>
{
if
(
fixedcodes
.
indexOf
(
rc
)
>=
0
)
{
return
true
;
}
else
{
return
false
;
}
});
if
(
rcs
.
length
===
0
)
{
res
.
json
(
System
.
getResult
(
null
,
"当前登录人没有资质宝访问权限"
));
return
}
//先按照openid去查看是否已经存在
let
uf
=
await
userS
.
dao
.
model
.
findOne
({
where
:
{
openid
:
openid
}
});
if
(
!
uf
)
{
//按照公司companykey查询出要注册公司的所在公司,取公司id
let
company
=
await
companyS
.
dao
.
model
.
findOne
({
where
:
{
companykey
:
companykey
}
});
//构造注册用户对象,需要设置默认角色,默认角色需要按照rolecode查询出角色
let
rolesfind
=
await
roleS
.
dao
.
model
.
findAll
({
where
:
{
code
:
{
[
roleS
.
db
.
Op
.
in
]:
rcs
},
company_id
:
company
.
id
}
});
//根据rolecode--,设置组织路径
let
opath
=
''
;
let
isSalesman
=
false
;
let
isDelivery
=
false
;
let
skilltags
=
new
Set
();
if
(
rcs
.
includes
(
"资质宝交付员"
))
{
isDelivery
=
true
;
opath
=
"root10/dlivergroup/dgroupmembers/"
+
userName
;
skilltags
.
add
(
"icp,edi"
);
}
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
let
reguser
=
{
company_id
:
company
.
id
,
userName
:
userName
,
nickName
:
nickName
,
roles
:
rolesfind
.
map
(
r
=>
r
.
id
),
opath
:
opath
,
openid
:
openid
,
isSalesman
:
isSalesman
,
isDelivery
:
isDelivery
,
isAllocated
:
true
,
skilltags
:
[...
skilltags
].
join
()
}
uf
=
await
userS
.
registerByTantent
(
reguser
);
}
let
rtnobj
=
await
userS
.
loginApp
(
appkey
,
userName
);
res
.
json
(
System
.
getResult
({
openurl
:
rtnobj
.
homePage
+
"?code="
+
rtnobj
.
code
}));
}
catch
(
e
)
{
res
.
json
(
System
.
getResult
(
null
,
e
.
message
));
}
})
app
.
post
(
"/entService/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
post
(
"/entService/*"
,
async
function
(
req
,
res
,
next
)
{
try
{
try
{
let
channel
;
let
channel
;
...
...
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