login / register ui
This commit is contained in:
parent
ae511a3871
commit
d1d2d08330
5 changed files with 158 additions and 7 deletions
31
init.js
31
init.js
|
@ -1,31 +1,48 @@
|
|||
import { importRouters } from "./lib.js";
|
||||
|
||||
const aliases = {
|
||||
'/': '/walls/get/home'
|
||||
};
|
||||
|
||||
const routers = {
|
||||
'/you': './you.js'
|
||||
}
|
||||
|
||||
function doAliases(app) {
|
||||
for (let alias in aliases) {
|
||||
app.all(alias, (req,res,next) => {
|
||||
app.all(alias, (req, res, next) => {
|
||||
res.redirect(aliases[alias])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function doInit(app) {
|
||||
async function doInit(app) {
|
||||
app.use((req, res, next) => {
|
||||
let headerCtx = [
|
||||
{ link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' },
|
||||
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
||||
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon
|
||||
];
|
||||
|
||||
if (!res.auth || !res.auth.valid) {
|
||||
headerCtx = [
|
||||
{ link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' },
|
||||
{ link: '/you/login', icon: '/walls.svg', name: 'Log in' }
|
||||
];
|
||||
}
|
||||
|
||||
res.ctx = {
|
||||
mainPage: '404.ejs',
|
||||
mainCtx: {},
|
||||
headerCtx: [
|
||||
{ link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' },
|
||||
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
||||
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon
|
||||
]
|
||||
headerCtx
|
||||
};
|
||||
next();
|
||||
})
|
||||
|
||||
doAliases(app);
|
||||
|
||||
await importRouters(app,routers);
|
||||
|
||||
app.use('/api', (req, res, next) => {
|
||||
res.send(res.ctx);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue