Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Move captcha keys to app.module.ts / remove config files #617

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
!/uploads/temp/index.html

# Configuration
/src/plugins/*/admin/database/migrations
/src/plugins/core/
5 changes: 5 additions & 0 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { PluginsModule } from './plugins/plugins.module';
config: DATABASE_ENVS,
schemaDatabase,
},
// captcha: {
// type: 'cloudflare_turnstile',
// secret_key: '',
// site_key: '',
// },
// email: emailResend({
// api_key: process.env.EMAIL_RESEND_API_KEY,
// from: process.env.EMAIL_RESEND_FROM,
Expand Down
46 changes: 0 additions & 46 deletions apps/frontend/src/plugins/admin/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@
"send_testing_email": "Send Testing Email"
}
},
"security": {
"captcha": {
"title": "Captcha",
"desc": "Captcha is a security feature that requires users to complete a challenge to prove they are human. This helps prevent spam and abuse.",
"type": {
"title": "Type",
"none": {
"title": "None"
},
"recaptcha_desc": "Read more on <link>Google reCAPTCHA</link>.",
"recaptcha_v2_invisible": "reCAPTCHA v2 Invisible",
"recaptcha_v2_checkbox": "reCAPTCHA v2 Checkbox",
"recaptcha_v3": "reCAPTCHA v3",
"cloudflare_turnstile": {
"title": "Cloudflare Turnstile",
"desc": "Read more on <link>Cloudflare Turnstile</link>."
}
},
"site_key": "Site Key",
"secret_key": "Secret Key"
}
},
"authorization": {
"title": "Authorization",
"desc": "Manage authorization settings for your website.",
Expand Down Expand Up @@ -569,30 +547,6 @@
"submit": "Yes, delete file"
}
}
},
"security": {
"spam": {
"title": "Spam Protection",
"captcha": {
"title": "Captcha",
"type": {
"title": "Type",
"none": {
"title": "None"
},
"recaptcha_desc": "Read more on <link>Google reCAPTCHA</link>.",
"recaptcha_v2_invisible": "reCAPTCHA v2 Invisible",
"recaptcha_v2_checkbox": "reCAPTCHA v2 Checkbox",
"recaptcha_v3": "reCAPTCHA v3",
"cloudflare_turnstile": {
"title": "Cloudflare Turnstile",
"desc": "Read more on <link>Cloudflare Turnstile</link>."
}
},
"site_key": "Site Key",
"secret_key": "Secret Key"
}
}
}
},
"members": {
Expand Down
4 changes: 0 additions & 4 deletions apps/frontend/src/plugins/core/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@
"settings_email": "Email",
"settings_authorization": "Authorization",
"settings_legal": "Legal & Policies",
"security": "Security",
"security_spam": "Spam Protection",
"plugins": "Plugins",
"styles": "Styles",
"styles_theme-editor": "Theme Editor",
Expand All @@ -379,8 +377,6 @@
"can_manage_settings_authorization": "Can manage authorization settings?",
"can_manage_settings_legal": "Can manage legal settings?",
"can_manage_plugins": "Can manage plugins?",
"security": "Security",
"can_manage_security_spam": "Can manage spam protection?",
"styles": "Styles",
"can_manage_styles_theme-editor": "Can manage theme editor?",
"can_manage_styles_nav": "Can manage navigation?",
Expand Down
37 changes: 0 additions & 37 deletions packages/backend/scripts/generate-config.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/backend/scripts/generate-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,6 @@ export const generateManifest = async ({
process.exit(1);
}

const configPath = join(
process.cwd(),
'src',
'plugins',
'core',
'utils',
'config.json',
);

if (!existsSync(configPath)) {
console.log(
`⛔️ Config file not found in 'backend/utils/config.json' directory. "${configPath}"`,
);
process.exit(1);
}

const languages = await db.query.core_languages.findMany({
columns: {
code: true,
Expand Down
18 changes: 6 additions & 12 deletions packages/backend/scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import coreSchemaDatabase from '../src/database';
import { checkUpdateSchemaDatabase } from './check-update-schema-database';
import { copyFiles } from './copy-files';
import { generateDatabaseMigrations, runMigrations } from './database';
import { generateConfig } from './generate-config';
import { generateManifest } from './generate-manifest';
import { updatePlugins } from './update-plugins';

Expand Down Expand Up @@ -37,12 +36,7 @@ const init = async () => {

const pluginsPath = getPluginsPath();
console.log(
`${initConsole} [1/${skipDatabase ? 2 : 7}] Setup the project. Generating the config file...`,
);
await generateConfig({ pluginsPath });

console.log(
`${initConsole} [2/${skipDatabase ? 2 : 7}] Copying files into backend...`,
`${initConsole} [1/${skipDatabase ? 1 : 6}] Copying files into backend...`,
);
await copyFiles({ pluginsPath });

Expand All @@ -51,7 +45,7 @@ const init = async () => {
process.exit(0);
}

console.log(`${initConsole} [3/7] Generating database migrations...`);
console.log(`${initConsole} [2/6] Generating database migrations...`);
await generateDatabaseMigrations();

const database = createClientDatabase({
Expand All @@ -60,17 +54,17 @@ const init = async () => {
});

console.log(
`${initConsole} [4/7] Create tables in database using migrations...`,
`${initConsole} [3/6] Create tables in database using migrations...`,
);
await runMigrations();

console.log(`${initConsole} [5/7] Updating plugins...`);
console.log(`${initConsole} [4/6] Updating plugins...`);
await updatePlugins({ pluginsPath, db: database.db });

console.log(`${initConsole} [6/7] Checking and updating schema database...`);
console.log(`${initConsole} [5/6] Checking and updating schema database...`);
await checkUpdateSchemaDatabase({ db: database.db });

console.log(`${initConsole} [7/7] Generating the manifest files...`);
console.log(`${initConsole} [6/6] Generating the manifest files...`);
await generateManifest({ db: database.db });

console.log(`${initConsole} ✅ Project setup complete.`);
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { join } from 'path';

import { CoreModule } from './core/core.module';
import { SSOAuthItem } from './helpers/auth/sso/sso.service';
import { CaptchaConfig } from './helpers/captcha/captcha.service';
import { EmailSenderFunction } from './helpers/email/email-helpers.type';
import { GlobalHelpersModule } from './helpers/helpers.module';
import {
Expand Down Expand Up @@ -171,7 +172,9 @@ export class VitNodeCoreModule {
database,
email,
ssoLoginMethod,
captcha,
}: {
captcha?: CaptchaConfig;
database: DatabaseModuleArgs;
email?: EmailSenderFunction;
ssoLoginMethod?: SSOAuthItem[];
Expand Down Expand Up @@ -207,7 +210,7 @@ export class VitNodeCoreModule {
maxAge: 31536000,
},
}),
GlobalHelpersModule.register({ email, ssoLoginMethod }),
GlobalHelpersModule.register({ email, ssoLoginMethod, captcha }),
],
};
}
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/core/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { DashboardAdminModule } from './dashboard/dashboard.module';
import { LanguagesAdminModule } from './languages/languages.module';
import { MembersAdminModule } from './members/members.module';
import { PluginsAdminModule } from './plugins/plugins.module';
import { SecurityAdminModule } from './security/security.module';
import { SettingsAdminModule } from './settings/settings.module';
import { StylesAdminModule } from './styles/styles.module';

Expand All @@ -19,7 +18,6 @@ import { StylesAdminModule } from './styles/styles.module';
PluginsAdminModule,
StylesAdminModule,
AdvancedAdminModule,
SecurityAdminModule,
DashboardAdminModule,
],
})
Expand Down
11 changes: 0 additions & 11 deletions packages/backend/src/core/admin/auth/services/nav/core.nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ export const coreNav: ShowAuthAdminObj['nav'] = [
},
],
},
{
code: 'security',
icon: 'shield',
keywords: [],
children: [
{
code: 'spam',
keywords: ['spam', 'report', 'reporting', 'recaptcha'],
},
],
},
{
code: 'styles',
icon: 'paintbrush',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export const coreAdminPermissions: PermissionsStaffObj[] = [
'can_manage_settings_legal',
],
},
{
id: 'security',
permissions: ['can_manage_security_spam'],
},
{
id: 'can_manage_plugins',
permissions: [],
Expand Down

This file was deleted.

11 changes: 0 additions & 11 deletions packages/backend/src/core/admin/security/captcha/captcha.module.ts

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading