qumra-engine 2.0.42 → 2.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/auth/login.d.ts +2 -0
- package/dist/controllers/auth/login.js +22 -0
- package/dist/controllers/auth/logout.d.ts +2 -0
- package/dist/controllers/auth/logout.js +11 -0
- package/dist/middleware.js +2 -0
- package/dist/routers/index.d.ts +2 -0
- package/dist/routers/index.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loginController = void 0;
|
|
4
|
+
const loginController = async (req, res) => {
|
|
5
|
+
const { redirect_url, token } = req.query;
|
|
6
|
+
console.log("🚀 ~ app.get ~ req.query:", req.query);
|
|
7
|
+
if (!redirect_url || !token) {
|
|
8
|
+
return res.status(400).send("Missing redirect_url or token");
|
|
9
|
+
}
|
|
10
|
+
res.cookie("authrization", token, {
|
|
11
|
+
httpOnly: false,
|
|
12
|
+
secure: process.env.NODE_ENV === "production",
|
|
13
|
+
expires: new Date(9999, 0, 1),
|
|
14
|
+
});
|
|
15
|
+
if (redirect_url) {
|
|
16
|
+
res.redirect(redirect_url);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
res.redirect("/");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.loginController = loginController;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logoutController = void 0;
|
|
4
|
+
const logoutController = async (req, res) => {
|
|
5
|
+
res.clearCookie("authrization", {
|
|
6
|
+
httpOnly: true,
|
|
7
|
+
secure: process.env.NODE_ENV === "production",
|
|
8
|
+
});
|
|
9
|
+
res.redirect("/");
|
|
10
|
+
};
|
|
11
|
+
exports.logoutController = logoutController;
|
package/dist/middleware.js
CHANGED
|
@@ -20,6 +20,7 @@ const mergeData_middleware_1 = require("./middleware/mergeData.middleware");
|
|
|
20
20
|
const express_session_1 = __importDefault(require("express-session"));
|
|
21
21
|
const printServerLog_1 = require("./utils/printServerLog");
|
|
22
22
|
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
23
|
+
const routers_1 = __importDefault(require("./routers"));
|
|
23
24
|
const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo, themeId = null, currentApp, }) => {
|
|
24
25
|
try {
|
|
25
26
|
const app = (0, express_1.default)();
|
|
@@ -52,6 +53,7 @@ const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo
|
|
|
52
53
|
if (mode === "devlopment") {
|
|
53
54
|
const staticPath = path_1.default.join(process.cwd(), "assets");
|
|
54
55
|
app.use("/assets", express_1.default.static(staticPath));
|
|
56
|
+
app.use('api', routers_1.default);
|
|
55
57
|
}
|
|
56
58
|
app.use((req, res, next) => {
|
|
57
59
|
if (!(0, isPathAllowedToRender_1.isPathAllowedToRender)(res.locals.parsedUrl.pathname)) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/routes/app.routes.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const login_1 = require("../controllers/auth/login");
|
|
6
|
+
const logout_1 = require("../controllers/auth/logout");
|
|
7
|
+
const router = (0, express_1.Router)();
|
|
8
|
+
router.post("/auth/login", login_1.loginController);
|
|
9
|
+
router.post("/auth/logout", logout_1.logoutController);
|
|
10
|
+
exports.default = router;
|