mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-13 04:02:56 +08:00
Add multi-user backend infrastructure: User model, management service and API
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
co-authored by
whyour
parent
4758400df6
commit
db93ca9aa9
@@ -42,6 +42,18 @@ export default ({ app }: { app: Application }) => {
|
||||
return next();
|
||||
});
|
||||
|
||||
// Extract userId and role from JWT
|
||||
app.use((req: Request, res, next) => {
|
||||
if (req.auth) {
|
||||
const payload = req.auth as any;
|
||||
req.user = {
|
||||
userId: payload.userId,
|
||||
role: payload.role,
|
||||
};
|
||||
}
|
||||
return next();
|
||||
});
|
||||
|
||||
app.use(async (req: Request, res, next) => {
|
||||
if (!['/open/', '/api/'].some((x) => req.path.startsWith(x))) {
|
||||
return next();
|
||||
|
||||
Reference in New Issue
Block a user