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
36da0228
Commit
36da0228
authored
Apr 24, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
e63772b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
11 deletions
+45
-11
center-manage/app/base/controller/impl/auth/userCtl.js
+0
-1
center-manage/app/base/db/cache/appCache.js
+33
-0
center-manage/app/base/service/impl/auth/userSve.js
+11
-10
center-manage/app/config/settings.js
+1
-0
No files found.
center-manage/app/base/controller/impl/auth/userCtl.js
View file @
36da0228
...
...
@@ -33,7 +33,6 @@ class UserCtl extends CtlBase {
if
(
!
p
.
companykey
)
{
return
system
.
getResult
(
null
,
"自有用户创建需要提供公司KEY"
);
}
p
.
rolecode
=
"pr"
;
let
rtn
=
await
this
.
service
.
pmregisterByFreeUser
(
p
,
q
);
return
rtn
;
}
...
...
center-manage/app/base/db/cache/appCache.js
0 → 100644
View file @
36da0228
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
//缓存首次登录的赠送的宝币数量
class
AppCache
extends
CacheBase
{
constructor
()
{
super
();
}
// isdebug() {
// return settings.env == "dev";
// }
desc
()
{
return
"应用服务实体缓存"
;
}
prefix
()
{
return
"g_vcode_"
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
//inputkey采用appkey_mobile的形式
var
mobile
=
inputkey
;
var
tmplCode
=
val
;
var
signName
=
items
?
items
[
0
]
:
""
;
var
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
if
(
!
tmplCode
&&
!
signName
)
{
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
}
//tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else
{
this
.
smsUtil
.
aliSendMsg
(
mobile
,
tmplCode
,
signName
,
JSON
.
stringify
({
code
:
vcode
}));
}
return
JSON
.
stringify
({
vcode
:
vcode
});
}
}
module
.
exports
=
VCodeCache
;
center-manage/app/base/service/impl/auth/userSve.js
View file @
36da0228
...
...
@@ -15,14 +15,14 @@ class UserService extends ServiceBase {
//按照用户名和密码进行注册
//控制器端检查用户名和密码非空
async
registerByTantent
(
p
,
q
){
p
.
rolecode
=
"pr"
;
p
.
rolecode
s
=
[
settings
.
pmroleid
[
"pr"
]]
;
let
rtn
=
await
this
.
pmregister
(
p
,
q
)
return
rtn
;
}
//应用的自由用户注册,无需验证,需要前端头设置公司KEY
async
pmregisterByFreeUser
(
p
,
q
){
p
.
rolecode
=
"pr"
;
p
.
rolecode
s
=
[
settings
.
pmroleid
[
"pr"
]]
;
let
rtn
=
await
this
.
pmregister
(
p
,
q
)
return
rtn
;
}
...
...
@@ -44,8 +44,8 @@ class UserService extends ServiceBase {
//对于租户类型注册,创建一个默认公司,公司名称xxxx的公司
//如果非租户类型,需要按照传递进来的公司companykey,来查询公司,按照companykey缓存到redis
let
cmpkey
=
self
.
getUUID
();
let
rolecode
=
p
.
rolecode
?
p
.
rolecode
:
"ta"
;
if
(
rolecode
==
"ta"
)
{
//如果注册时,角色是租户,那么需要创建默认公司
let
rolecode
s
=
p
.
rolecode
?
p
.
rolecodes
:
[
settings
.
pmroleid
[
"ta"
]]
;
if
(
rolecode
s
[
0
]
==
settings
.
pmroleid
[
"ta"
]
)
{
//如果注册时,角色是租户,那么需要创建默认公司
let
cmp
=
await
self
.
companyDao
.
create
({
name
:
p
.
userName
+
"的公司"
,
companykey
:
cmpkey
},
t
);
p
.
company_id
=
cmp
.
id
;
}
else
{
...
...
@@ -60,10 +60,11 @@ class UserService extends ServiceBase {
//设置默认角色,租户
//设置默认普通角色,由于有了租户概念,所以注册时,需要知道当前租户和应用的id 才可以设置默认角色 todo
var
role
=
await
self
.
roleDao
.
model
.
findOne
({
where
:
{
code
:
rolecode
},
transaction
:
t
});
await
u
.
setRoles
([
role
],
{
transaction
:
t
});
//创建统一账号
var
roles
=
await
self
.
roleDao
.
model
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
rolecodes
}
}
},
transaction
:
t
});
if
(
roles
&&
roles
.
length
>
0
){
await
u
.
setRoles
(
roles
,
{
transaction
:
t
});
}
//创建统一账号 to add extra fields
let
cred
=
await
self
.
cregister
(
u
.
userName
,
p
.
company_id
,
p
.
password
)
console
.
log
(
"......................................"
);
console
.
log
(
cred
.
consumer
.
id
);
...
...
@@ -132,7 +133,7 @@ class UserService extends ServiceBase {
//自由用户的电话登录和注册
//需要存在公司KEY
async
pmloginByVCodeForFreeUser
(
p
,
q
){
p
.
rolecode
=
"pr"
p
.
rolecodes
=
[
settings
.
pmroleid
[
"pr"
]];
let
rtn
=
await
this
.
pmloginByVCode
(
p
,
q
,
req
)
return
system
.
getResult
(
rtn
);
}
...
...
@@ -164,7 +165,7 @@ class UserService extends ServiceBase {
return
rtn
;
}
else
{
//先按照用户名查续身份信息,获取key,secret,
let
u
=
await
this
.
pmregister
({
userName
:
mobile
,
nickName
:
mobile
,
rolecode
:
p
.
rolecode
,
companykey
:
p
.
companykey
});
let
u
=
await
this
.
pmregister
({
userName
:
mobile
,
nickName
:
mobile
,
rolecode
s
:
p
.
rolecodes
,
companykey
:
p
.
companykey
});
let
token
=
await
this
.
cmakejwt
(
u
.
jwtkey
,
u
.
jwtsecret
,
null
);
rtn
.
token
=
token
;
rtn
.
user
=
u
;
...
...
center-manage/app/config/settings.js
View file @
36da0228
...
...
@@ -20,6 +20,7 @@ var settings = {
kongurl
:
"http://192.168.4.119:8001/"
,
pmappid
:
1
,
pmcompanyid
:
1
,
pmroleid
:{
"ta"
:
1
,
"pr"
:
2
},
redis
:
function
(){
if
(
this
.
env
==
"dev"
){
var
localsettings
=
require
(
"./localsettings"
);
...
...
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