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
01c4de34
Commit
01c4de34
authored
May 11, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
c540810d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
center-manage/app/base/db/cache/userCache.js
+7
-4
center-manage/app/base/service/impl/auth/userSve.js
+15
-0
No files found.
center-manage/app/base/db/cache/userCache.js
View file @
01c4de34
...
...
@@ -16,14 +16,17 @@ class UserCache extends CacheBase{
return
"g_userlocal_"
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
const
configValue
=
await
this
.
userDao
.
model
.
find
One
({
const
configValue
=
await
this
.
userDao
.
model
.
find
All
({
where
:
{
userName
:
inputkey
,
app_id
:
settings
.
pmappid
},
attributes
:
[
'id'
,
'userName'
,
'nickName'
,
'headUrl'
,
'jwtkey'
,
'jwtsecret'
,
'created_at'
,
'isSuper'
,
'isAdmin'
,
'mail'
],
include
:
[{
model
:
this
.
db
.
models
.
company
,
raw
:
true
}],
include
:
[
{
model
:
this
.
db
.
models
.
company
,
raw
:
true
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:[
"id"
,
"code"
],}
],
});
if
(
configValue
)
{
return
JSON
.
stringify
(
configValue
);
if
(
configValue
&&
configValue
[
0
]
)
{
return
JSON
.
stringify
(
configValue
[
0
]
);
}
return
null
;
}
...
...
center-manage/app/base/service/impl/auth/userSve.js
View file @
01c4de34
...
...
@@ -7,6 +7,7 @@ class UserService extends ServiceBase {
super
(
"auth"
,
ServiceBase
.
getDaoName
(
UserService
));
this
.
companyDao
=
system
.
getObject
(
"db.common.companyDao"
);
this
.
roleDao
=
system
.
getObject
(
"db.auth.roleDao"
);
this
.
authS
=
system
.
getObject
(
"service.auth.authSve"
);
}
//登录后的租户创建属于租户的用户
...
...
@@ -115,6 +116,13 @@ class UserService extends ServiceBase {
if
(
userfind
)
{
let
token
=
await
self
.
cmakejwt
(
userfind
.
jwtkey
,
userfind
.
jwtsecret
,
null
);
rtn
.
token
=
token
;
let
roleids
=
userfind
.
Roles
.
map
(
item
=>
{
return
item
.
id
})
let
auths
=
await
this
.
authS
.
findAuthsByRole
(
roleids
)
userfind
[
"access"
]
=
auths
delete
userfind
[
"jwtkey"
]
delete
userfind
[
"jwtsecret"
]
rtn
.
user
=
userfind
;
...
...
@@ -131,6 +139,13 @@ class UserService extends ServiceBase {
// include: [{ model: this.db.models.company, raw: true, attributes: ["companykey"] }]
// });
let
userfind
=
await
this
.
cacheManager
[
"UserCache"
].
cache
(
uname
)
//添加当前用户的权限信息
let
roleids
=
userfind
.
Roles
.
map
(
item
=>
{
return
item
.
id
})
let
auths
=
await
this
.
authS
.
findAuthsByRole
(
roleids
)
userfind
[
"access"
]
=
auths
delete
userfind
[
"jwtkey"
]
delete
userfind
[
"jwtsecret"
]
return
userfind
;
...
...
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