Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Dui123
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
王天宇
Dui123
Commits
ae38e2e5
Commit
ae38e2e5
authored
Nov 04, 2021
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新dev
parent
71c1b99d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
users.js
server/routes/users.js
+22
-3
No files found.
server/routes/users.js
View file @
ae38e2e5
...
@@ -5,12 +5,31 @@ const configDev = require("../../config/dev.json");
...
@@ -5,12 +5,31 @@ const configDev = require("../../config/dev.json");
const
request
=
require
(
"request"
);
const
request
=
require
(
"request"
);
const
SsoOauth2
=
require
(
'sso-oauth2'
).
default
const
SsoOauth2
=
require
(
'sso-oauth2'
).
default
const
ssoOauth2
=
new
SsoOauth2
(
configDev
.
SSO
)
const
ssoOauth2
=
new
SsoOauth2
(
configDev
.
SSO
)
const
query
=
require
(
'../lib/query'
)
const
ErrorCode
=
{
const
ErrorCode
=
{
USER_NOT_LOGIN
:
70001
USER_NOT_LOGIN
:
70001
}
}
getMysql
.
then
(
Mysql
=>
{
getMysql
.
then
(
Mysql
=>
{
router
.
get
(
'/addAdmin'
,
async
(
req
,
res
)
=>
{
const
{
uid
}
=
req
.
query
const
SQL
=
'UPDATE `user` SET `admin` = 1 WHERE `uid` = ?'
try
{
const
addAdmin
=
await
query
(
SQL
,
[
uid
])
res
.
send
({
success
:
true
,
result
:
addAdmin
})
}
catch
(
e
)
{
console
.
error
(
e
)
res
.
send
({
success
:
false
,
err
:
e
})
}
})
/* GET users listing. */
/* GET users listing. */
router
.
get
(
'/getUser'
,
async
(
req
,
res
)
=>
{
router
.
get
(
'/getUser'
,
async
(
req
,
res
)
=>
{
const
{
sso_ticket
}
=
req
.
cookies
const
{
sso_ticket
}
=
req
.
cookies
...
@@ -36,7 +55,7 @@ getMysql.then(Mysql => {
...
@@ -36,7 +55,7 @@ getMysql.then(Mysql => {
return
return
}
}
if
(
Array
.
isArray
(
result
)
&&
result
.
length
>
0
)
{
if
(
Array
.
isArray
(
result
)
&&
result
.
length
>
0
)
{
console
.
info
(
'用户查询:'
,
result
)
console
.
info
(
'用户查询:'
,
result
)
const
admin
=
+
result
[
0
][
'admin'
]
===
1
?
{
admin
:
result
[
0
][
'admin'
]}
:
{}
const
admin
=
+
result
[
0
][
'admin'
]
===
1
?
{
admin
:
result
[
0
][
'admin'
]}
:
{}
res
.
send
({
res
.
send
({
success
:
true
,
success
:
true
,
...
@@ -44,9 +63,9 @@ getMysql.then(Mysql => {
...
@@ -44,9 +63,9 @@ getMysql.then(Mysql => {
})
})
}
else
{
}
else
{
const
_SQL
=
'INSERT INTO `user` (uid, uname, follow) VALUES (?,?,?)'
const
_SQL
=
'INSERT INTO `user` (uid, uname, follow) VALUES (?,?,?)'
const
_params
=
[
ssoData
[
'id'
],
ssoData
[
'name'
],
JSON
.
stringify
([])]
const
_params
=
[
ssoData
[
'id'
],
ssoData
[
'name'
],
JSON
.
stringify
([])]
Mysql
.
query
(
_SQL
,
_params
,
(
_err
,
_result
)
=>
{
Mysql
.
query
(
_SQL
,
_params
,
(
_err
,
_result
)
=>
{
if
(
_err
){
if
(
_err
)
{
console
.
error
(
_err
)
console
.
error
(
_err
)
res
.
send
({
res
.
send
({
success
:
false
,
success
:
false
,
...
...
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