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
f6c1cea1
Commit
f6c1cea1
authored
Nov 29, 2019
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
e55a97ca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
bigdata/app/base/api/impl/auth/accessAuth.js
+58
-0
bigdata/app/base/db/models/auth/user.js
+1
-0
bigdata/app/base/service/impl/auth/userSve.js
+4
-0
No files found.
bigdata/app/base/api/impl/auth/accessAuth.js
View file @
f6c1cea1
...
...
@@ -167,6 +167,64 @@ class AccessAuthAPI extends APIBase {
await
this
.
cacheManager
[
"OpenCodeCache"
].
cache
(
opencode
,
ruser
,
120
);
return
system
.
getResultSuccess
({
auth_url
:
authUrl
,
opencode
:
opencode
});
}
//根据openid查询是否与用户绑定
async
checkWxBind
(
p
,
q
,
req
){
var
openid
=
p
.
openid
;
if
(
!
openid
)
{
return
system
.
getResult
(
null
,
"openid不能为空"
);
}
var
param
=
{
app_id
:
req
.
app
.
id
,
openid
:
openid
,
}
var
ruser
=
await
this
.
userSve
.
checkWxBind
(
param
);
if
(
!
ruser
){
return
system
.
getResult
(
null
,
"用户未绑定微信"
);
}
return
system
.
getResult
(
ruser
);
}
//wxbind
async
wxBind
(
pobj
,
qobj
,
req
)
{
var
appkey
=
req
.
app
.
appkey
;
if
(
!
pobj
.
mobile
)
{
return
system
.
getResult
(
null
,
"电话号码不能未空."
);
}
if
(
!
pobj
.
vcode
)
{
return
system
.
getResult
(
null
,
"验证码不能未空."
);
}
if
(
!
pobj
.
openid
)
{
return
system
.
getResult
(
null
,
"openid不能未空."
);
}
var
cacheCode
=
await
this
.
cacheManager
[
"VCodeCache"
].
cache
(
appkey
+
"_"
+
pobj
.
mobile
,
null
);
if
(
pobj
.
vcode
!=
cacheCode
.
vcode
)
{
return
system
.
getResult
(
system
.
verifyVCodeFail
,
"验证码校验不成功,请重新获取验证码验证."
);
}
var
param
=
{
app_id
:
req
.
app
.
id
,
mobile
:
pobj
.
mobile
,
openid
:
pobj
.
openid
}
var
ruser
=
await
this
.
userSve
.
wxBind
(
param
);
if
(
!
ruser
)
{
param
=
{
app_id
:
req
.
app
.
id
,
userName
:
pobj
.
mobile
,
nickName
:
pobj
.
mobile
,
mobile
:
pobj
.
mobile
,
password
:
pobj
.
mobile
,
wxopenid
:
pobj
.
openid
}
ruser
=
await
this
.
userSve
.
register
(
param
);
}
var
opencode
=
super
.
getUUID
();
var
authUrl
=
req
.
app
.
authUrl
+
"?opencode="
+
opencode
;
await
this
.
cacheManager
[
"OpenCodeCache"
].
cache
(
opencode
,
ruser
,
120
);
return
system
.
getResultSuccess
({
auth_url
:
authUrl
,
opencode
:
opencode
});
}
//根据openid登录
async
loginByMobileWithReg
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
mobile
)
{
return
system
.
getResult
(
null
,
"电话不能为空"
);
...
...
bigdata/app/base/db/models/auth/user.js
View file @
f6c1cea1
...
...
@@ -34,6 +34,7 @@ module.exports = (db, DataTypes) => {
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
wxopenid
:
DataTypes
.
STRING
,
app_id
:
DataTypes
.
INTEGER
,
account_id
:
DataTypes
.
INTEGER
,
isEnabled
:{
...
...
bigdata/app/base/service/impl/auth/userSve.js
View file @
f6c1cea1
...
...
@@ -309,6 +309,10 @@ class UserService extends ServiceBase {
}
return
user
;
}
async
checkWxBind
(
u
){
var
user
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
wxopenid
:
u
.
openid
,
app_id
:
u
.
app_id
}});
return
user
;
}
async
getUserByUserNamePwd
(
u
)
{
//勇于从别的应用中,点击页面连接,跳转到平台应用中进行管理
if
(
!
u
.
isNavto
){
...
...
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