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
b60b65d1
Commit
b60b65d1
authored
Aug 24, 2020
by
王悦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tx_uin 验证码登录
parent
32455d75
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
5 deletions
+80
-5
center-manage/app/base/controller/impl/auth/userCtl.js
+8
-0
center-manage/app/base/db/cache/userCache.js
+2
-2
center-manage/app/base/db/models/auth/user.js
+3
-1
center-manage/app/base/service/impl/auth/captchaSve.js
+65
-0
center-manage/app/base/service/impl/auth/userSve.js
+2
-2
No files found.
center-manage/app/base/controller/impl/auth/userCtl.js
View file @
b60b65d1
...
...
@@ -6,6 +6,7 @@ const CtlBase = require("../../ctl.base");
class
UserCtl
extends
CtlBase
{
constructor
()
{
super
(
"auth"
,
CtlBase
.
getServiceName
(
UserCtl
));
this
.
captchaSve
=
system
.
getObject
(
"service.auth.captchaSve"
);
}
async
logout
(
pobj
,
qobj
,
req
)
{
let
rtn
=
await
this
.
service
.
logout
(
pobj
)
...
...
@@ -105,6 +106,9 @@ class UserCtl extends CtlBase {
}
async
pmlogin
(
pobj
,
qobj
,
req
)
{
//平台注册设置平台的应用ID
let
verifyres
=
await
this
.
captchaSve
.
apiValidator
({
key
:
pobj
.
key
,
code
:
pobj
.
code
});
if
(
verifyres
.
status
!==
0
)
return
verifyres
;
let
rtn
=
await
this
.
service
.
pmlogin
(
pobj
,
qobj
,
req
);
let
msg
=
null
if
(
!
rtn
)
{
//登录错误
...
...
@@ -158,6 +162,10 @@ class UserCtl extends CtlBase {
let
rtn
=
await
this
.
service
.
sendVCode
(
pobj
,
qobj
);
return
system
.
getResult
(
rtn
);
}
async
pmPicVerifyCode
(
pobj
,
qobj
,
req
)
{
let
rtn
=
await
this
.
captchaSve
.
apiGenerate
(
pobj
,
qobj
);
return
system
.
getResult
(
rtn
);
}
}
module
.
exports
=
UserCtl
;
center-manage/app/base/db/cache/userCache.js
View file @
b60b65d1
...
...
@@ -8,7 +8,7 @@ class UserCache extends CacheBase {
this
.
channelDao
=
system
.
getObject
(
"db.common.channelDao"
);
}
isdebug
()
{
return
settings
.
env
==
"
dev
"
;
return
settings
.
env
==
"
localhost
"
;
}
desc
()
{
return
"缓存本地应用对象"
;
...
...
@@ -19,7 +19,7 @@ class UserCache extends CacheBase {
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
const
configValue
=
await
this
.
userDao
.
model
.
findAll
({
where
:
{
userName
:
inputkey
,
app_id
:
settings
.
pmappid
,
isEnabled
:
true
},
attributes
:
[
'id'
,
'userName'
,
'nickName'
,
'headUrl'
,
'jwtkey'
,
'jwtsecret'
,
'created_at'
,
'isSuper'
,
'isAdmin'
,
'isAllocated'
,
'mail'
,
'mobile'
,
'opath'
,
'ptags'
],
attributes
:
[
'id'
,
'userName'
,
'nickName'
,
'headUrl'
,
'jwtkey'
,
'jwtsecret'
,
'created_at'
,
'isSuper'
,
'isAdmin'
,
'isAllocated'
,
'mail'
,
'mobile'
,
'opath'
,
'ptags'
,
'tx_uin'
],
include
:
[
{
model
:
this
.
db
.
models
.
company
,
attributes
:
[
'id'
,
'name'
,
'companykey'
,
'appids'
,
"code"
],
raw
:
true
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:
[
"id"
,
"code"
],
}
...
...
center-manage/app/base/db/models/auth/user.js
View file @
b60b65d1
...
...
@@ -47,7 +47,6 @@ module.exports = (db, DataTypes) => {
},
last_change_date
:
{
type
:
DataTypes
.
DATE
,
defaultValue
:
false
},
isSuper
:
{
type
:
DataTypes
.
BOOLEAN
,
...
...
@@ -79,6 +78,9 @@ module.exports = (db, DataTypes) => {
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
tx_uin
:
{
type
:
DataTypes
.
STRING
,
},
isDelivery
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
...
...
center-manage/app/base/service/impl/auth/captchaSve.js
0 → 100644
View file @
b60b65d1
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
uuidv4
=
require
(
'uuid/v4'
);
var
svgCaptcha
=
require
(
'svg-captcha'
);
class
CaptchaService
{
constructor
()
{
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
}
async
apiGenerate
(
params
)
{
var
key
=
uuidv4
();
var
options
=
{
size
:
4
,
noise
:
1
,
ignoreChars
:
'0o1iILl'
};
options
.
width
=
this
.
trim
(
params
.
width
)
||
120
;
options
.
height
=
this
.
trim
(
params
.
height
)
||
32
;
options
.
background
=
this
.
trim
(
params
.
background
)
||
"#E8E8E8"
;
var
captchaPrev
=
this
.
trim
(
params
.
captchaPrev
);
var
expire
=
Number
(
params
.
expire
||
3
*
60
)
try
{
var
cap
=
svgCaptcha
.
create
(
options
);
console
.
log
(
cap
);
await
this
.
redisClient
.
setWithEx
(
key
,
cap
.
text
,
expire
);
return
system
.
getResultSuccess
({
key
:
key
,
text
:
cap
.
text
,
captcha
:
cap
.
data
,
});
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
"接口异常:"
+
error
.
message
);
}
}
async
apiValidator
(
params
)
{
var
key
=
this
.
trim
(
params
.
key
);
var
code
=
this
.
trim
(
params
.
code
);
var
cacheCode
=
await
this
.
redisClient
.
get
(
key
);
if
(
!
cacheCode
)
{
return
system
.
getResult
(
null
,
"验证码已过期,请点击重试"
);
}
if
(
code
.
toLowerCase
()
!=
cacheCode
.
toLowerCase
())
{
await
this
.
redisClient
.
delete
(
key
);
return
system
.
getResult
(
null
,
"验证码输入错误,清点击重试"
);
}
return
system
.
getResultSuccess
(
1
);
}
trim
(
o
)
{
if
(
!
o
)
{
return
""
;
}
return
o
.
toString
().
trim
();
}
}
module
.
exports
=
CaptchaService
;
\ No newline at end of file
center-manage/app/base/service/impl/auth/userSve.js
View file @
b60b65d1
...
...
@@ -429,7 +429,7 @@ class UserService extends ServiceBase {
let
companyFind
=
await
self
.
companyDao
.
model
.
findOne
({
where
:
{
name
:
spName
},
include
:
[
{
model
:
self
.
db
.
models
.
user
,
as
:
"us"
,
attributes
:
[
'id'
,
'userName'
,
'mobile'
,
'isAllocated'
,
'opath'
,
'skilltags'
,
'regiontags'
,
'isAllArea'
,
'isSalesman'
,
'isDelivery'
],
raw
:
true
model
:
self
.
db
.
models
.
user
,
as
:
"us"
,
attributes
:
[
'id'
,
'userName'
,
'mobile'
,
'isAllocated'
,
'opath'
,
'skilltags'
,
'regiontags'
,
'isAllArea'
,
'isSalesman'
,
'isDelivery'
,
'tx_uin'
],
raw
:
true
}
],
excludes
:
[
'orgJson'
],
transaction
:
t
});
...
...
@@ -539,7 +539,7 @@ class UserService extends ServiceBase {
let
companyFind
=
await
self
.
companyDao
.
model
.
findOne
({
where
:
{
name
:
spName
},
include
:
[
{
model
:
self
.
db
.
models
.
user
,
as
:
"us"
,
attributes
:
[
'id'
,
'userName'
,
'mobile'
,
'isAllocated'
,
'opath'
,
'skilltags'
,
'regiontags'
,
'isAllArea'
,
'isSalesman'
,
'isDelivery'
],
raw
:
true
model
:
self
.
db
.
models
.
user
,
as
:
"us"
,
attributes
:
[
'id'
,
'userName'
,
'mobile'
,
'isAllocated'
,
'opath'
,
'skilltags'
,
'regiontags'
,
'isAllArea'
,
'isSalesman'
,
'isDelivery'
,
'tx_uin'
],
raw
:
true
}
],
excludes
:
[
'orgJson'
],
transaction
:
t
});
...
...
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