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
ff45071c
Commit
ff45071c
authored
Jan 07, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
0af66d74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
36 deletions
+59
-36
bigdata/app/base/api/impl/auth/accessAuth.js
+44
-36
bigdata/app/base/db/cache.base.js
+12
-0
bigdata/app/base/system.js
+3
-0
No files found.
bigdata/app/base/api/impl/auth/accessAuth.js
View file @
ff45071c
...
@@ -10,10 +10,10 @@ class AccessAuthAPI extends APIBase {
...
@@ -10,10 +10,10 @@ class AccessAuthAPI extends APIBase {
this
.
userSve
=
system
.
getObject
(
"service.auth.userSve"
);
this
.
userSve
=
system
.
getObject
(
"service.auth.userSve"
);
}
}
/*查询注册用户的信息sys*/
/*查询注册用户的信息sys*/
async
queryRegUser
(
pobj
,
query
,
req
){
async
queryRegUser
(
pobj
,
query
,
req
)
{
var
appid
=
req
.
app
.
id
;
var
appid
=
req
.
app
.
id
;
var
userList
=
await
this
.
userSve
.
queryUsersByAppId
(
appid
);
var
userList
=
await
this
.
userSve
.
queryUsersByAppId
(
appid
);
return
system
.
getResult
(
userList
);
return
system
.
getResult
(
userList
);
}
}
/**
/**
* 发送短信
* 发送短信
...
@@ -43,6 +43,10 @@ class AccessAuthAPI extends APIBase {
...
@@ -43,6 +43,10 @@ class AccessAuthAPI extends APIBase {
if
(
tmplCode
&&
tmplCode
.
indexOf
(
"SMS_"
)
<
0
)
{
if
(
tmplCode
&&
tmplCode
.
indexOf
(
"SMS_"
)
<
0
)
{
return
system
.
getResult
(
null
,
"模版编码有误"
);
return
system
.
getResult
(
null
,
"模版编码有误"
);
}
}
var
tmpReslut
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
appkey
+
"_"
+
mobile
);
if
(
tmpReslut
)
{
return
system
.
getResult
(
system
.
redoFail
,
"操作过于频繁,请勿重复获取"
);
}
var
vcodeResult
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
mobile
,
tmplCode
,
120
,
signName
);
var
vcodeResult
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
mobile
,
tmplCode
,
120
,
signName
);
return
system
.
getResult
(
vcodeResult
);
return
system
.
getResult
(
vcodeResult
);
}
}
...
@@ -58,7 +62,11 @@ class AccessAuthAPI extends APIBase {
...
@@ -58,7 +62,11 @@ class AccessAuthAPI extends APIBase {
if
(
!
mobile
)
{
if
(
!
mobile
)
{
return
system
.
getResult
(
null
,
"电话号码不能为空."
);
return
system
.
getResult
(
null
,
"电话号码不能为空."
);
}
}
var
vcodeResult
=
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
mobile
,
null
,
60
);
var
tmpReslut
=
await
this
.
cacheManager
[
"VCodeCache"
].
getCache
(
appkey
+
"_"
+
mobile
);
if
(
tmpReslut
)
{
return
system
.
getResult
(
system
.
redoFail
,
"操作过于频繁,请勿重复获取"
);
}
var
vcodeResult
=
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
mobile
,
null
,
120
);
return
system
.
getResult
(
vcodeResult
);
return
system
.
getResult
(
vcodeResult
);
}
}
async
authAccessKey
(
pobj
,
query
,
req
)
{
async
authAccessKey
(
pobj
,
query
,
req
)
{
...
@@ -178,7 +186,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -178,7 +186,7 @@ class AccessAuthAPI extends APIBase {
}
}
var
ruser
=
await
this
.
userSve
.
getUserByUserMobile
(
param
);
var
ruser
=
await
this
.
userSve
.
getUserByUserMobile
(
param
);
if
(
!
ruser
)
{
if
(
!
ruser
)
{
return
system
.
getResult
(
null
,
"查无此用户"
);
return
system
.
getResult
(
null
,
"查无此用户"
);
}
}
var
opencode
=
super
.
getUUID
();
var
opencode
=
super
.
getUUID
();
var
authUrl
=
req
.
app
.
authUrl
+
"?opencode="
+
opencode
;
var
authUrl
=
req
.
app
.
authUrl
+
"?opencode="
+
opencode
;
...
@@ -187,8 +195,8 @@ class AccessAuthAPI extends APIBase {
...
@@ -187,8 +195,8 @@ class AccessAuthAPI extends APIBase {
}
}
//根据openid查询是否与用户绑定
//根据openid查询是否与用户绑定
async
checkWxBind
(
p
,
q
,
req
)
{
async
checkWxBind
(
p
,
q
,
req
)
{
var
openid
=
p
.
openid
;
var
openid
=
p
.
openid
;
if
(
!
openid
)
{
if
(
!
openid
)
{
return
system
.
getResult
(
null
,
"openid不能为空"
);
return
system
.
getResult
(
null
,
"openid不能为空"
);
}
}
...
@@ -197,14 +205,14 @@ class AccessAuthAPI extends APIBase {
...
@@ -197,14 +205,14 @@ class AccessAuthAPI extends APIBase {
openid
:
openid
,
openid
:
openid
,
}
}
var
ruser
=
await
this
.
userSve
.
checkWxBind
(
param
);
var
ruser
=
await
this
.
userSve
.
checkWxBind
(
param
);
if
(
!
ruser
)
{
if
(
!
ruser
)
{
return
system
.
getResult
(
null
,
"用户未绑定微信"
);
return
system
.
getResult
(
null
,
"用户未绑定微信"
);
}
}
return
system
.
getResult
(
ruser
);
return
system
.
getResult
(
ruser
);
}
}
//根据openid登录
//根据openid登录
async
loginByOpenId
(
p
,
q
,
req
)
{
async
loginByOpenId
(
p
,
q
,
req
)
{
var
openid
=
p
.
openid
;
var
openid
=
p
.
openid
;
if
(
!
openid
)
{
if
(
!
openid
)
{
return
system
.
getResult
(
null
,
"openid不能为空"
);
return
system
.
getResult
(
null
,
"openid不能为空"
);
}
}
...
@@ -213,7 +221,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -213,7 +221,7 @@ class AccessAuthAPI extends APIBase {
openid
:
openid
,
openid
:
openid
,
}
}
var
ruser
=
await
this
.
userSve
.
checkWxBind
(
param
);
var
ruser
=
await
this
.
userSve
.
checkWxBind
(
param
);
if
(
!
ruser
)
{
if
(
!
ruser
)
{
return
system
.
getResult
(
null
,
"用户未绑定微信"
);
return
system
.
getResult
(
null
,
"用户未绑定微信"
);
}
}
var
opencode
=
super
.
getUUID
();
var
opencode
=
super
.
getUUID
();
...
@@ -234,23 +242,23 @@ class AccessAuthAPI extends APIBase {
...
@@ -234,23 +242,23 @@ class AccessAuthAPI extends APIBase {
return
system
.
getResult
(
null
,
"openid不能未空."
);
return
system
.
getResult
(
null
,
"openid不能未空."
);
}
}
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
if
(
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
if
(
!
cacheCode
||
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
return
system
.
getResult
(
system
.
verifyVCodeFail
,
"验证码校验不成功,请重新获取验证码验证."
);
return
system
.
getResult
(
system
.
verifyVCodeFail
,
"验证码校验不成功,请重新获取验证码验证."
);
}
}
var
param
=
{
var
param
=
{
app_id
:
req
.
app
.
id
,
app_id
:
req
.
app
.
id
,
mobile
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
openid
:
pobj
.
openid
openid
:
pobj
.
openid
}
}
var
ruser
=
await
this
.
userSve
.
wxBind
(
param
);
var
ruser
=
await
this
.
userSve
.
wxBind
(
param
);
if
(
!
ruser
)
{
if
(
!
ruser
)
{
param
=
{
param
=
{
app_id
:
req
.
app
.
id
,
app_id
:
req
.
app
.
id
,
userName
:
pobj
.
mobile
,
userName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
password
:
pobj
.
mobile
,
password
:
pobj
.
mobile
,
wxopenid
:
pobj
.
openid
wxopenid
:
pobj
.
openid
}
}
ruser
=
await
this
.
userSve
.
register
(
param
);
ruser
=
await
this
.
userSve
.
register
(
param
);
}
}
...
@@ -259,8 +267,8 @@ class AccessAuthAPI extends APIBase {
...
@@ -259,8 +267,8 @@ class AccessAuthAPI extends APIBase {
await
this
.
cacheManager
[
"OpenCodeCache"
].
cache
(
opencode
,
ruser
,
120
);
await
this
.
cacheManager
[
"OpenCodeCache"
].
cache
(
opencode
,
ruser
,
120
);
return
system
.
getResultSuccess
({
auth_url
:
authUrl
,
opencode
:
opencode
});
return
system
.
getResultSuccess
({
auth_url
:
authUrl
,
opencode
:
opencode
});
}
}
//wxbind
//wxbind
async
wxBindWithoutVCode
(
pobj
,
qobj
,
req
)
{
async
wxBindWithoutVCode
(
pobj
,
qobj
,
req
)
{
var
appkey
=
req
.
app
.
appkey
;
var
appkey
=
req
.
app
.
appkey
;
if
(
!
pobj
.
mobile
)
{
if
(
!
pobj
.
mobile
)
{
return
system
.
getResult
(
null
,
"电话号码不能未空."
);
return
system
.
getResult
(
null
,
"电话号码不能未空."
);
...
@@ -272,17 +280,17 @@ class AccessAuthAPI extends APIBase {
...
@@ -272,17 +280,17 @@ class AccessAuthAPI extends APIBase {
var
param
=
{
var
param
=
{
app_id
:
req
.
app
.
id
,
app_id
:
req
.
app
.
id
,
mobile
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
openid
:
pobj
.
openid
openid
:
pobj
.
openid
}
}
var
ruser
=
await
this
.
userSve
.
wxBind
(
param
);
var
ruser
=
await
this
.
userSve
.
wxBind
(
param
);
if
(
!
ruser
)
{
if
(
!
ruser
)
{
param
=
{
param
=
{
app_id
:
req
.
app
.
id
,
app_id
:
req
.
app
.
id
,
userName
:
pobj
.
mobile
,
userName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
password
:
pobj
.
mobile
,
password
:
pobj
.
mobile
,
wxopenid
:
pobj
.
openid
wxopenid
:
pobj
.
openid
}
}
ruser
=
await
this
.
userSve
.
register
(
param
);
ruser
=
await
this
.
userSve
.
register
(
param
);
}
}
...
@@ -305,7 +313,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -305,7 +313,7 @@ class AccessAuthAPI extends APIBase {
param
=
{
param
=
{
app_id
:
req
.
app
.
id
,
app_id
:
req
.
app
.
id
,
userName
:
pobj
.
mobile
,
userName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
password
:
pobj
.
mobile
password
:
pobj
.
mobile
}
}
...
@@ -338,9 +346,9 @@ class AccessAuthAPI extends APIBase {
...
@@ -338,9 +346,9 @@ class AccessAuthAPI extends APIBase {
/**
/**
* 按照手机号和验证码修改密码
* 按照手机号和验证码修改密码
*/
*/
async
modiPasswordByMobile
(
pobj
,
qobj
,
req
){
async
modiPasswordByMobile
(
pobj
,
qobj
,
req
)
{
var
appid
=
req
.
app
.
id
;
var
appid
=
req
.
app
.
id
;
var
appkey
=
req
.
app
.
appkey
;
var
appkey
=
req
.
app
.
appkey
;
if
(
!
pobj
.
mobile
)
{
if
(
!
pobj
.
mobile
)
{
return
system
.
getResult
(
null
,
"电话号码不能未空."
);
return
system
.
getResult
(
null
,
"电话号码不能未空."
);
}
}
...
@@ -351,19 +359,19 @@ class AccessAuthAPI extends APIBase {
...
@@ -351,19 +359,19 @@ class AccessAuthAPI extends APIBase {
return
system
.
getResult
(
null
,
"新密码不能未空."
);
return
system
.
getResult
(
null
,
"新密码不能未空."
);
}
}
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
if
(
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
if
(
!
cacheCode
||
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
return
system
.
getResultFail
(
-
1
,
"验证码校验不成功,请重新获取验证码验证."
,
system
.
verifyVCodeFail
);
return
system
.
getResultFail
(
-
1
,
"验证码校验不成功,请重新获取验证码验证."
,
system
.
verifyVCodeFail
);
}
}
//按照appid和电话查询出要修改的用户
//按照appid和电话查询出要修改的用户
var
ruser
=
await
this
.
userSve
.
modiPasswordByMobile
(
appid
,
pobj
.
mobile
,
pobj
.
newPwd
);
var
ruser
=
await
this
.
userSve
.
modiPasswordByMobile
(
appid
,
pobj
.
mobile
,
pobj
.
newPwd
);
return
system
.
getResult
(
ruser
);
return
system
.
getResult
(
ruser
);
}
}
/**
/**
* 按照账号和appid修改密码
* 按照账号和appid修改密码
*/
*/
async
modiPasswordByUserName
(
pobj
,
qobj
,
req
){
async
modiPasswordByUserName
(
pobj
,
qobj
,
req
)
{
var
appid
=
req
.
app
.
id
;
var
appid
=
req
.
app
.
id
;
if
(
!
pobj
.
userName
)
{
if
(
!
pobj
.
userName
)
{
return
system
.
getResult
(
null
,
"账号不能未空."
);
return
system
.
getResult
(
null
,
"账号不能未空."
);
}
}
if
(
!
pobj
.
newPwd
)
{
if
(
!
pobj
.
newPwd
)
{
...
@@ -372,7 +380,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -372,7 +380,7 @@ class AccessAuthAPI extends APIBase {
// if (!pobj.oldPwd) {
// if (!pobj.oldPwd) {
// return system.getResult(null, "旧密码不能未空.");
// return system.getResult(null, "旧密码不能未空.");
// }
// }
var
ruser
=
await
this
.
userSve
.
modiPasswordByUserName
(
appid
,
pobj
.
userName
,
pobj
.
newPwd
,
pobj
.
oldPwd
);
var
ruser
=
await
this
.
userSve
.
modiPasswordByUserName
(
appid
,
pobj
.
userName
,
pobj
.
newPwd
,
pobj
.
oldPwd
);
return
system
.
getResult
(
ruser
);
return
system
.
getResult
(
ruser
);
}
}
/**
/**
...
@@ -390,7 +398,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -390,7 +398,7 @@ class AccessAuthAPI extends APIBase {
return
system
.
getResult
(
null
,
"验证码不能未空."
);
return
system
.
getResult
(
null
,
"验证码不能未空."
);
}
}
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
if
(
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
if
(
!
cacheCode
||
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
return
system
.
getResult
(
system
.
verifyVCodeFail
,
"验证码校验不成功,请重新获取验证码验证."
);
return
system
.
getResult
(
system
.
verifyVCodeFail
,
"验证码校验不成功,请重新获取验证码验证."
);
}
}
var
param
=
{
var
param
=
{
...
@@ -402,7 +410,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -402,7 +410,7 @@ class AccessAuthAPI extends APIBase {
param
=
{
param
=
{
app_id
:
req
.
app
.
id
,
app_id
:
req
.
app
.
id
,
userName
:
pobj
.
mobile
,
userName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
password
:
pobj
.
mobile
password
:
pobj
.
mobile
}
}
...
@@ -716,7 +724,7 @@ class AccessAuthAPI extends APIBase {
...
@@ -716,7 +724,7 @@ class AccessAuthAPI extends APIBase {
methodName
:
"queryRegUser"
,
methodName
:
"queryRegUser"
,
paramdescs
:
[
paramdescs
:
[
{
{
}
}
],
],
rtnTypeDesc
:
"返回应用的注册用户"
,
rtnTypeDesc
:
"返回应用的注册用户"
,
...
...
bigdata/app/base/db/cache.base.js
View file @
ff45071c
...
@@ -38,6 +38,18 @@ class CacheBase {
...
@@ -38,6 +38,18 @@ class CacheBase {
return
JSON
.
parse
(
cacheValue
);
return
JSON
.
parse
(
cacheValue
);
}
}
}
}
async
getCache
(
inputkey
,
ex
)
{
const
cachekey
=
this
.
prefix
+
inputkey
;
var
cacheValue
=
await
this
.
redisClient
.
get
(
cachekey
);
if
(
!
cacheValue
||
cacheValue
==
"undefined"
||
cacheValue
==
"null"
)
{
return
null
;
}
else
{
if
(
ex
)
{
this
.
redisClient
.
set
(
cachekey
,
cacheValue
,
ex
);
}
return
JSON
.
parse
(
cacheValue
);
}
}
async
invalidate
(
inputkey
)
{
async
invalidate
(
inputkey
)
{
const
cachekey
=
this
.
prefix
+
inputkey
;
const
cachekey
=
this
.
prefix
+
inputkey
;
this
.
redisClient
.
delete
(
cachekey
);
this
.
redisClient
.
delete
(
cachekey
);
...
...
bigdata/app/base/system.js
View file @
ff45071c
...
@@ -174,6 +174,9 @@ System.userNameLoginFail = 2020;
...
@@ -174,6 +174,9 @@ System.userNameLoginFail = 2020;
System
.
verifyVCodeFail
=
2030
;
System
.
verifyVCodeFail
=
2030
;
//opencode存储的值已经失效
//opencode存储的值已经失效
System
.
verifyOpencodeFail
=
2040
;
System
.
verifyOpencodeFail
=
2040
;
//重复操作
System
.
redoFail
=
2050
;
module
.
exports
=
System
;
module
.
exports
=
System
;
// rc=System.getObject("tool.restClient");
// rc=System.getObject("tool.restClient");
...
...
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