mirror of https://github.com/Facinorous-420/dick
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
958 B
31 lines
958 B
import { Request, Response, Router } from "express"
|
|
import { getSettingsDatabase } from "../utils/database"
|
|
import { TEMPLATE } from "../constants"
|
|
import { Pager } from "../Pager"
|
|
|
|
export const publicRoutes = (app: Router) => {
|
|
app.get("/login", async (req: Request, res: Response) => {
|
|
// If the user is already logged in via cookies, redirect them to the dashboard
|
|
if (req.user) {
|
|
return res.redirect('/')
|
|
}
|
|
|
|
await Pager.render(res, req, TEMPLATE.PUBLIC, {})
|
|
})
|
|
|
|
app.get("/register", async (req: Request, res: Response) => {
|
|
// If the user is already logged in via cookies, redirect them to the dashboard
|
|
if (req.user) {
|
|
return res.redirect('/')
|
|
}
|
|
|
|
const database = getSettingsDatabase()
|
|
if (!database.registrationEnabled){
|
|
req.flash('error_message', 'Registration is not enabled!')
|
|
return res.redirect("/login")
|
|
}
|
|
|
|
await Pager.render(res, req, TEMPLATE.PUBLIC, {})
|
|
})
|
|
}
|