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
e188adb7
Commit
e188adb7
authored
Dec 14, 2019
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
bbb9e050
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
110 deletions
+97
-110
bpo-stat/app/base/db/models/auth/user.js
+1
-1
bpo-stat/app/config/environment.js
+1
-1
bpo-stat/app/config/routes/web.js
+95
-108
No files found.
bpo-stat/app/base/db/models/auth/user.js
View file @
e188adb7
...
@@ -24,7 +24,7 @@ module.exports = (db, DataTypes) => {
...
@@ -24,7 +24,7 @@ module.exports = (db, DataTypes) => {
indexes
:
[
indexes
:
[
// Create a unique index on email
// Create a unique index on email
// {
// {
// unique: true,
// unique: true,
sign_body
// fields: ['email']
// fields: ['email']
// },
// },
//
//
...
...
bpo-stat/app/config/environment.js
View file @
e188adb7
...
@@ -27,7 +27,7 @@ module.exports = function (app) {
...
@@ -27,7 +27,7 @@ module.exports = function (app) {
app
.
all
(
'*'
,
function
(
req
,
res
,
next
)
{
app
.
all
(
'*'
,
function
(
req
,
res
,
next
)
{
req
.
objs
=
system
;
req
.
objs
=
system
;
res
.
header
(
'Access-Control-Allow-Origin'
,
'*'
);
res
.
header
(
'Access-Control-Allow-Origin'
,
'*'
);
res
.
header
(
'Access-Control-Allow-Headers'
,
'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild,
xggadmin
sid'
);
res
.
header
(
'Access-Control-Allow-Headers'
,
'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild,
bpostat
sid'
);
res
.
header
(
'Access-Control-Allow-Methods'
,
'PUT, POST, GET, DELETE, OPTIONS'
);
res
.
header
(
'Access-Control-Allow-Methods'
,
'PUT, POST, GET, DELETE, OPTIONS'
);
// res.header('Access-Control-Allow-Credentials', 'true');
// res.header('Access-Control-Allow-Credentials', 'true');
if
(
req
.
method
==
'OPTIONS'
)
{
if
(
req
.
method
==
'OPTIONS'
)
{
...
...
bpo-stat/app/config/routes/web.js
View file @
e188adb7
...
@@ -5,118 +5,105 @@ var userCtl = system.getObject("web.auth.userCtl");
...
@@ -5,118 +5,105 @@ var userCtl = system.getObject("web.auth.userCtl");
const
redisClient
=
system
.
getObject
(
"util.redisClient"
);
const
redisClient
=
system
.
getObject
(
"util.redisClient"
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
// app.all("/web/*", async function (req, res, next) {
app
.
all
(
"/web/*"
,
async
function
(
req
,
res
,
next
)
{
// var xggadminsid;
let
bpostatsid
=
req
.
headers
[
"bpostatsid"
]
||
""
;
// var jsonUser = req.session.user;
jsonUser
=
await
redisClient
.
get
(
bpostatsid
);
// // var jsonUser = null;
if
(
jsonUser
)
{
// if(!jsonUser) {
jsonUser
=
JSON
.
parse
(
jsonUser
);
// xggadminsid = req.headers["xggadminsid"] || "";
}
// jsonUser = await redisClient.get(xggadminsid);
// if(jsonUser) {
// jsonUser = JSON.parse(jsonUser);
// }
// }
//
// if (req.url.indexOf("auth/userCtl/login") > 0 ||
// req.url.indexOf("uc/userCtl/login") > 0 ||
// req.url.indexOf("auth/userCtl/smsCode") > 0 ||
// req.url.indexOf("common/metaCtl/getApiDoc") > 0 ||
// req.url.indexOf("common/captchaCtl/captcha") > 0 ||
//
// req.url.indexOf("getRsConfig") > 0) {
// if (jsonUser) {
// req.loginUser = jsonUser;
// } else {
// req.loginUser = null;
// }
// return next();
// }
//
// if (!jsonUser) {
// res.end(JSON.stringify({ status: -99, msg: "no login" }));
// return;
// }
//
// if(xggadminsid) {
// redisClient.setWithEx(xggadminsid, JSON.stringify(jsonUser), 60 * 60 * 60);
// }
//
// req.loginUser = jsonUser;
// // if(req.loginUser.uctype != 3) {
// // res.end(JSON.stringify({ status: -99, msg: "no deliver user, kick off" }));
// // return;
// // }
// req.loginUser = jsonUser;
// next();
// });
app
.
get
(
"/"
,
async
function
(
req
,
res
)
{
if
(
req
.
url
.
indexOf
(
"auth/userCtl/login"
)
>
0
||
res
.
render
(
"index"
,
{
appinfo
:
null
,
app
:
null
});
req
.
url
.
indexOf
(
"auth/userCtl/register"
)
>
0
||
req
.
url
.
indexOf
(
"getRsConfig"
)
>
0
)
{
// console.log(req.hostname);
if
(
jsonUser
)
{
// var appinfo=await metaCtl.getAppInfo(req);
req
.
loginUser
=
jsonUser
;
// if(!appinfo){
}
else
{
// res.render("index",{appinfo:null,app:null});
req
.
loginUser
=
null
;
// }else{
}
// res.render("index",appinfo);
return
next
();
// }
}
});
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
params
=
[];
if
(
req
.
loginUser
)
{
if
(
!
jsonUser
)
{
req
.
query
=
req
.
query
||
{};
res
.
end
(
JSON
.
stringify
({
status
:
-
99
,
msg
:
"no login"
}));
req
.
query
.
sign_body
=
req
.
loginUser
.
sign_body
;
return
;
}
}
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
res
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
p
=
invokeObj
[
"doexec"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
console
.
log
(
req
.
url
,
"req.url..................."
);
console
.
log
(
r
,
"req###############################"
);
res
.
end
(
JSON
.
stringify
(
r
));
});
});
app
.
post
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
if
(
bpostatsid
)
{
var
classPath
=
req
.
params
[
"qname"
];
redisClient
.
setWithEx
(
bpostatsid
,
JSON
.
stringify
(
jsonUser
),
60
*
60
*
60
);
var
methodName
=
req
.
params
[
"method"
];
}
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
body
.
clientIp
=
tClientIp
;
req
.
body
.
agent
=
req
.
headers
[
"user-agent"
];
req
.
body
.
classname
=
classPath
;
if
(
req
.
loginUser
)
{
req
.
loginUser
=
jsonUser
;
req
.
body
.
saas_id
=
req
.
loginUser
.
saas_id
;
next
();
req
.
body
.
sign_body
=
req
.
loginUser
.
sign_body
;
});
}
params
.
push
(
methodName
);
app
.
get
(
"/"
,
async
function
(
req
,
res
)
{
params
.
push
(
req
.
body
);
res
.
render
(
"index"
,
{
appinfo
:
null
,
app
:
null
});
params
.
push
(
req
.
query
);
params
.
push
(
req
);
// console.log(req.hostname);
params
.
push
(
res
);
// var appinfo=await metaCtl.getAppInfo(req);
var
p
=
null
;
// if(!appinfo){
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
// res.render("index",{appinfo:null,app:null});
if
(
invokeObj
[
"doexec"
])
{
// }else{
p
=
invokeObj
[
"doexec"
].
apply
(
invokeObj
,
params
);
// res.render("index",appinfo);
}
// }
p
.
then
(
r
=>
{
});
res
.
end
(
JSON
.
stringify
(
r
));
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
});
var
classPath
=
req
.
params
[
"qname"
];
});
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
params
=
[];
if
(
req
.
loginUser
)
{
req
.
query
=
req
.
query
||
{};
req
.
query
.
sign_body
=
req
.
loginUser
.
sign_body
;
}
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
res
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
p
=
invokeObj
[
"doexec"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
console
.
log
(
req
.
url
,
"req.url..................."
);
console
.
log
(
r
,
"req###############################"
);
res
.
end
(
JSON
.
stringify
(
r
));
});
});
app
.
post
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
body
.
clientIp
=
tClientIp
;
req
.
body
.
agent
=
req
.
headers
[
"user-agent"
];
req
.
body
.
classname
=
classPath
;
if
(
req
.
loginUser
)
{
req
.
body
.
saas_id
=
req
.
loginUser
.
saas_id
;
req
.
body
.
sign_body
=
req
.
loginUser
.
sign_body
;
}
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
res
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
p
=
invokeObj
[
"doexec"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
});
});
};
};
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