fix: replace express-ejs-layouts with EJS partial includes (header/footer)
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -30,7 +30,6 @@
|
|||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.7",
|
||||||
"ejs": "^6.0.1",
|
"ejs": "^6.0.1",
|
||||||
"express-ejs-layouts": "^2.5.1",
|
|
||||||
"helmet": "^8.0.0",
|
"helmet": "^8.0.0",
|
||||||
"ioredis": "^5.5.0",
|
"ioredis": "^5.5.0",
|
||||||
"nestjs-pino": "^4.1.0",
|
"nestjs-pino": "^4.1.0",
|
||||||
@@ -6473,11 +6472,6 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/express-ejs-layouts": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/express-ejs-layouts/-/express-ejs-layouts-2.5.1.tgz",
|
|
||||||
"integrity": "sha512-IXROv9n3xKga7FowT06n1Qn927JR8ZWDn5Dc9CJQoiiaaDqbhW5PDmWShzbpAa2wjWT1vJqaIM1S6vJwwX11gA=="
|
|
||||||
},
|
|
||||||
"node_modules/express/node_modules/cookie-signature": {
|
"node_modules/express/node_modules/cookie-signature": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.7",
|
||||||
"ejs": "^6.0.1",
|
"ejs": "^6.0.1",
|
||||||
"express-ejs-layouts": "^2.5.1",
|
|
||||||
"helmet": "^8.0.0",
|
"helmet": "^8.0.0",
|
||||||
"ioredis": "^5.5.0",
|
"ioredis": "^5.5.0",
|
||||||
"nestjs-pino": "^4.1.0",
|
"nestjs-pino": "^4.1.0",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { Logger } from 'nestjs-pino';
|
|||||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
import * as helmet from 'helmet';
|
import * as helmet from 'helmet';
|
||||||
import cookieParser from 'cookie-parser';
|
import cookieParser from 'cookie-parser';
|
||||||
import expressLayouts from 'express-ejs-layouts';
|
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import { existsSync } from 'node:fs';
|
import { existsSync } from 'node:fs';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
@@ -42,8 +41,6 @@ async function bootstrap(): Promise<void> {
|
|||||||
if (existsSync(viewsPath)) {
|
if (existsSync(viewsPath)) {
|
||||||
app.setBaseViewsDir(viewsPath);
|
app.setBaseViewsDir(viewsPath);
|
||||||
app.setViewEngine('ejs');
|
app.setViewEngine('ejs');
|
||||||
app.use(expressLayouts);
|
|
||||||
app.set('layout', 'layouts/main');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicPath = join(process.cwd(), 'public');
|
const publicPath = join(process.cwd(), 'public');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%- include('../partials/header') %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<ul class="nav nav-tabs mb-3">
|
<ul class="nav nav-tabs mb-3">
|
||||||
@@ -117,3 +118,4 @@
|
|||||||
else alert('Failed to delete client');
|
else alert('Failed to delete client');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<%- include('../partials/footer') %>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%- include('../partials/header') %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
@@ -137,3 +138,4 @@
|
|||||||
else alert('Failed to delete user');
|
else alert('Failed to delete user');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<%- include('../partials/footer') %>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%- include('../partials/header') %>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
@@ -164,3 +165,4 @@
|
|||||||
el.classList.remove('d-none');
|
el.classList.remove('d-none');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<%- include('../partials/footer') %>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%- include('../partials/header') %>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
@@ -56,3 +57,4 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<%- include('../partials/footer') %>
|
||||||
|
|||||||
11
views/partials/footer.ejs
Normal file
11
views/partials/footer.ejs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
</div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script>
|
||||||
|
function logout() {
|
||||||
|
localStorage.removeItem('access_token');
|
||||||
|
localStorage.removeItem('refresh_token');
|
||||||
|
window.location.href = '/login';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
30
views/partials/header.ejs
Normal file
30
views/partials/header.ejs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>SSO - <%= title || 'Auth Panel' %></title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body class="bg-light">
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="/">SSO Service</a>
|
||||||
|
<div class="collapse navbar-collapse">
|
||||||
|
<ul class="navbar-nav ms-auto">
|
||||||
|
<% if (locals.user) { %>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/profile">Profile</a></li>
|
||||||
|
<% if (user.role === 'ADMIN') { %>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/admin">Admin</a></li>
|
||||||
|
<% } %>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="#" onclick="logout()">Logout</a></li>
|
||||||
|
<% } else { %>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/login">Login</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/register">Register</a></li>
|
||||||
|
<% } %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container">
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%- include('../partials/header') %>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="card shadow">
|
<div class="card shadow">
|
||||||
@@ -68,3 +69,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<%- include('../partials/footer') %>
|
||||||
|
|||||||
Reference in New Issue
Block a user