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
e087d5ce
Commit
e087d5ce
authored
Jan 16, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tn
parent
17334402
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
27 deletions
+28
-27
bigdata/app/base/api/impl/auth/accessAuth.js
+13
-7
bigdata/app/base/db/cache/vcodeCache.js
+15
-20
No files found.
bigdata/app/base/api/impl/auth/accessAuth.js
View file @
e087d5ce
...
...
@@ -8,6 +8,7 @@ class AccessAuthAPI extends APIBase {
this
.
apitradeSvr
=
system
.
getObject
(
"service.common.apitradeSve"
);
this
.
authUtils
=
system
.
getObject
(
"util.businessManager.authUtils"
);
this
.
userSve
=
system
.
getObject
(
"service.auth.userSve"
);
this
.
vCodeExTime
=
120
;
//验证码缓存秒数
}
/*查询注册用户的信息sys*/
async
queryRegUser
(
pobj
,
query
,
req
)
{
...
...
@@ -47,7 +48,7 @@ class AccessAuthAPI extends APIBase {
return
system
.
getResultFail
(
system
.
redoFail
,
"操作过于频繁,请勿重复获取"
,
system
.
redoFail
);
}
pobj
.
reqType
=
"otherVcode"
;
var
vcodeResult
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
cacheKeyStr
,
pobj
,
120
,
null
);
var
vcodeResult
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
cacheKeyStr
,
pobj
,
this
.
vCodeExTime
,
null
);
return
system
.
getResult
(
vcodeResult
);
}
/**
...
...
@@ -78,11 +79,13 @@ class AccessAuthAPI extends APIBase {
if
(
tmplCode
&&
tmplCode
.
indexOf
(
"SMS_"
)
<
0
)
{
return
system
.
getResult
(
null
,
"模版编码有误"
);
}
var
tmpReslut
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
appkey
+
"_"
+
mobile
);
var
cacheKeyStr
=
appkey
+
"_"
+
pobj
.
mobile
;
var
tmpReslut
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
cacheKeyStr
);
if
(
tmpReslut
)
{
return
system
.
getResultFail
(
system
.
redoFail
,
"操作过于频繁,请勿重复获取"
,
system
.
redoFail
);
}
var
vcodeResult
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
mobile
,
tmplCode
,
120
,
signName
);
pobj
.
reqType
=
"defaultOtherVcode"
;
var
vcodeResult
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
cacheKeyStr
,
pobj
,
this
.
vCodeExTime
,
null
);
return
system
.
getResult
(
vcodeResult
);
}
/**
...
...
@@ -97,11 +100,13 @@ class AccessAuthAPI extends APIBase {
if
(
!
mobile
)
{
return
system
.
getResult
(
null
,
"电话号码不能为空."
);
}
var
tmpReslut
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
appkey
+
"_"
+
mobile
);
var
cacheKeyStr
=
appkey
+
"_"
+
pobj
.
mobile
;
var
tmpReslut
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
cacheKeyStr
);
if
(
tmpReslut
)
{
return
system
.
getResultFail
(
system
.
redoFail
,
"操作过于频繁,请勿重复获取"
,
system
.
redoFail
);
}
var
vcodeResult
=
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
mobile
,
null
,
120
);
pobj
.
reqType
=
"defaultVcode"
;
var
vcodeResult
=
this
.
cacheManager
[
"VCodeCache"
].
cache
(
cacheKeyStr
,
pobj
,
this
.
vCodeExTime
,
null
);
return
system
.
getResult
(
vcodeResult
);
}
async
authAccessKey
(
pobj
,
query
,
req
)
{
...
...
@@ -276,7 +281,8 @@ class AccessAuthAPI extends APIBase {
if
(
!
pobj
.
openid
)
{
return
system
.
getResult
(
null
,
"openid不能未空."
);
}
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
var
cacheKeyStr
=
appkey
+
"_"
+
pobj
.
mobile
;
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
cacheKeyStr
);
if
(
!
cacheCode
||
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
return
system
.
getResultFail
(
system
.
verifyVCodeFail
,
"验证码校验不成功,请重新获取验证码验证."
,
system
.
verifyVCodeFail
);
}
...
...
@@ -394,7 +400,7 @@ class AccessAuthAPI extends APIBase {
return
system
.
getResult
(
null
,
"新密码不能未空."
);
}
var
cacheKeyStr
=
appkey
+
"_"
+
pobj
.
mobile
;
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
cacheKeyStr
,
null
);
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
cacheKeyStr
);
if
(
!
cacheCode
||
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
return
system
.
getResultFail
(
-
1
,
"验证码校验不成功,请重新获取验证码验证."
+
pobj
.
vcode
+
"--"
+
cacheCode
.
vcode
,
system
.
verifyVCodeFail
);
}
...
...
bigdata/app/base/db/cache/vcodeCache.js
View file @
e087d5ce
...
...
@@ -17,29 +17,24 @@ class VCodeCache extends CacheBase {
return
"g_vcode:appkey_"
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
//【XXX】您的验证码是:602639(5分钟内有效),工作人员不会索取,请勿泄露。-------描述在模板中配置
var
pobj
=
val
;
var
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
if
(
!
pobj
)
{
//inputkey采用appkey_mobile的形式
var
mobile
=
inputkey
.
split
(
"_"
)[
1
];
var
tmplCode
=
val
;
var
signName
=
items
?
items
[
0
]
:
""
;
// var content=tmpl.replace(/\|vcode\|/g,vcode);
//this.smsUtil.sendMsg(mobile,content);
if
(
!
tmplCode
&&
!
signName
)
{
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
}
//tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else
{
this
.
smsUtil
.
aliSendMsg
(
mobile
,
tmplCode
,
signName
,
JSON
.
stringify
({
code
:
vcode
}));
if
(
pobj
&&
pobj
.
reqType
)
{
switch
(
pobj
.
reqType
)
{
case
"defaultVcode"
:
this
.
smsUtil
.
sendMsg
(
pobj
.
mobile
,
vcode
);
break
;
case
"defaultOtherVcode"
:
this
.
smsUtil
.
aliSendMsg
(
pobj
.
mobile
,
pobj
.
tmplCode
,
pobj
.
signName
,
JSON
.
stringify
({
code
:
vcode
}));
break
;
case
"otherVcode"
:
this
.
smsUtil
.
aliOtherSendMsg
(
pobj
.
mobile
,
pobj
.
accessKeyId
,
pobj
.
accessKeySecret
,
pobj
.
tmplCode
,
pobj
.
signName
,
JSON
.
stringify
({
code
:
vcode
}));
break
;
default
:
break
;
}
return
JSON
.
stringify
({
vcode
:
vcode
});
}
if
(
pobj
.
reqType
==
"otherVcode"
)
{
//【XXX】您的验证码是:602639(5分钟内有效),工作人员不会索取,请勿泄露。-------描述在模板中配置
pobj
.
msgContent
=
vcode
;
this
.
smsUtil
.
aliOtherSendMsg
(
pobj
.
mobile
,
pobj
.
accessKeyId
,
pobj
.
accessKeySecret
,
pobj
.
tmplCode
,
pobj
.
signName
,
JSON
.
stringify
({
code
:
vcode
}));
}
return
JSON
.
stringify
({
vcode
:
vcode
});
}
...
...
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