feat: custom branding (#112)

* add first concept

* remove setup status

* split config page in multiple components

* add custom branding docs

* add test email button

* fix invalid email from header

* add migration

* mount images to host

* update docs

* remove unused endpoint

* run formatter
This commit is contained in:
Elias Schneider
2023-03-04 23:29:00 +01:00
committed by GitHub
parent f9840505b8
commit fddad3ef70
66 changed files with 908 additions and 623 deletions

View File

@@ -15,9 +15,8 @@ export async function middleware(request: NextRequest) {
const routes = {
unauthenticated: new Routes(["/auth/*", "/"]),
public: new Routes(["/share/*", "/upload/*"]),
setupStatusRegistered: new Routes(["/auth/*", "/admin/setup"]),
admin: new Routes(["/admin/*"]),
account: new Routes(["/account/*"]),
account: new Routes(["/account*"]),
disabled: new Routes([]),
};
@@ -45,41 +44,28 @@ export async function middleware(request: NextRequest) {
user = null;
}
if (!getConfig("ALLOW_REGISTRATION")) {
if (!getConfig("share.allowRegistration")) {
routes.disabled.routes.push("/auth/signUp");
}
if (getConfig("ALLOW_UNAUTHENTICATED_SHARES")) {
if (getConfig("share.allowUnauthenticatedShares")) {
routes.public.routes = ["*"];
}
if (!getConfig("SMTP_ENABLED")) {
if (!getConfig("smtp.enabled")) {
routes.disabled.routes.push("/auth/resetPassword*");
}
if (getConfig("SETUP_STATUS") == "FINISHED") {
routes.disabled.routes.push("/admin/setup");
}
// prettier-ignore
const rules = [
// Disabled routes
{
condition: routes.disabled.contains(route),
path: "/",
},
// Setup status
{
condition: getConfig("SETUP_STATUS") == "STARTED" && route != "/auth/signUp",
path: "/auth/signUp",
},
{
condition: getConfig("SETUP_STATUS") == "REGISTERED" && !routes.setupStatusRegistered.contains(route) && user?.isAdmin,
path: "/admin/setup",
},
// Authenticated state
{
condition: user && routes.unauthenticated.contains(route) && !getConfig("ALLOW_UNAUTHENTICATED_SHARES"),
condition: user && routes.unauthenticated.contains(route) && !getConfig("share.allowUnauthenticatedShares"),
path: "/upload",
},
// Unauthenticated state
@@ -98,7 +84,7 @@ export async function middleware(request: NextRequest) {
},
// Home page
{
condition: (!getConfig("SHOW_HOME_PAGE") || user) && route == "/",
condition: (!getConfig("general.showHomePage") || user) && route == "/",
path: "/upload",
},
];