Skip to content

Commit

Permalink
Merge pull request #476 from VitNode/settings/disable_sign_up
Browse files Browse the repository at this point in the history
feat: Add block Sign Up option in AdminCP
  • Loading branch information
aXenDeveloper authored Sep 1, 2024
2 parents 57edb82 + 3ea5416 commit 765ebb7
Show file tree
Hide file tree
Showing 36 changed files with 1,548 additions and 1,815 deletions.
20 changes: 10 additions & 10 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"@nestjs/schedule": "^4.1.0",
"@nestjs/serve-static": "^4.0.2",
"pg": "^8.12.0",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-dom": "19.0.0-rc-fb9a90fa48-20240614",
"react": "19.0.0-rc-e56f4ae3-20240830",
"react-dom": "19.0.0-rc-e56f4ae3-20240830",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
},
Expand All @@ -34,20 +34,20 @@
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-document-nodes": "^4.0.9",
"@graphql-codegen/typescript-operations": "^4.2.3",
"@nestjs/cli": "^10.4.4",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@react-email/components": "^0.0.22",
"@react-email/components": "^0.0.24",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.18",
"@swc/core": "^1.7.22",
"@types/express": "^4.17.21",
"@types/node": "^22.5.0",
"@types/pg": "^8.11.6",
"@types/react": "^18.3.4",
"@types/node": "^22.5.1",
"@types/pg": "^8.11.8",
"@types/react": "^18.3.5",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cross-env": "^7.0.3",
"drizzle-kit": "^0.23.1",
"drizzle-orm": "^0.32.1",
"drizzle-kit": "^0.24.2",
"drizzle-orm": "^0.33.0",
"eslint-config-typescript-vitnode": "workspace:*",
"object-path": "^0.11.8",
"source-map-support": "^0.5.21",
Expand Down
4 changes: 3 additions & 1 deletion apps/backend/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type AuthorizationAdminSessionsObj {

type AuthorizationCoreMiddleware {
force_login: Boolean!
lock_register: Boolean!
}

type AuthorizationCoreSessionsObj {
Expand Down Expand Up @@ -216,7 +217,7 @@ input LogosEditAdminThemeEditor {
}

type Mutation {
admin__core_authorization_settings__edit(force_login: Boolean!): ShowAdminAuthorizationSettingsObj!
admin__core_authorization_settings__edit(force_login: Boolean!, lock_register: Boolean!): ShowAdminAuthorizationSettingsObj!
admin__core_email_settings__edit(color_primary: String!, color_primary_foreground: String!, logo: UploadWithKeepCoreFilesArgs, provider: EmailProvider!, resend_key: String, smtp: SMTPEditAdminEmailSettingsService): ShowAdminEmailSettingsServiceObj!
admin__core_email_settings__test(from: String!, message: String!, preview_text: String, subject: String!, to: String!): String!
admin__core_files__delete(id: Int!): String!
Expand Down Expand Up @@ -331,6 +332,7 @@ type SecurityCoreMiddleware {

type ShowAdminAuthorizationSettingsObj {
force_login: Boolean!
lock_register: Boolean!
}

type ShowAdminCaptchaSecurityObj {
Expand Down
16 changes: 8 additions & 8 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
},
"dependencies": {
"geist": "^1.3.1",
"lucide-react": "^0.435.0",
"next": "15.0.0-canary.110",
"next-intl": "^3.17.6",
"react": "19.0.0-rc-b57d2823-20240822",
"react-dom": "19.0.0-rc-b57d2823-20240822",
"lucide-react": "^0.437.0",
"next": "15.0.0-canary.137",
"next-intl": "^3.19.0",
"react": "19.0.0-rc-e56f4ae3-20240830",
"react-dom": "19.0.0-rc-e56f4ae3-20240830",
"vitnode-frontend": "workspace:*"
},
"devDependencies": {
"@next/bundle-analyzer": "15.0.0-canary.101",
"@types/node": "^22.5.0",
"@types/react": "^18.3.4",
"@types/node": "^22.5.1",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.20",
"eslint-config-typescript-vitnode": "workspace:*",
"graphql-tag": "^2.12.6",
"postcss": "^8.4.41",
"postcss": "^8.4.42",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.4"
}
Expand Down
4 changes: 4 additions & 0 deletions apps/frontend/src/plugins/admin/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
"force_login": {
"title": "Force Login",
"desc": "This option will block your site access from guest users."
},
"lock_register": {
"title": "Lock Register",
"desc": "This option will lock users from registering on your site."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"eslint-config-typescript-vitnode": "workspace:*",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.6",
"turbo": "^2.0.14",
"turbo": "^2.1.1",
"typescript": "^5.5.4"
},
"packageManager": "[email protected]"
Expand Down
32 changes: 16 additions & 16 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
],
"peerDependencies": {
"@nestjs/apollo": "^12",
"@nestjs/common": "^10.3.10",
"@nestjs/core": "^10.3.10",
"@nestjs/graphql": "^12",
"@react-email/components": "^0.0.23",
"@nestjs/common": "^10.4.1",
"@nestjs/core": "^10.4.1",
"@nestjs/graphql": "^12.2.0",
"@react-email/components": "^0.0.24",
"class-validator": "^0.14.1",
"drizzle-kit": "^0.24.1",
"drizzle-kit": "^0.24.2",
"drizzle-orm": "^0.33.0",
"react": "^19.0.0-rc.0",
"react-dom": "^19.0.0-rc.0",
"react": "^19",
"react-dom": "^19",
"typescript": "^5.5.4"
},
"dependencies": {
Expand All @@ -67,9 +67,9 @@
"@nestjs/schedule": "^4.1.0",
"@nestjs/serve-static": "^4.0.2",
"@nestjs/throttler": "^6.2.1",
"@react-email/render": "^1.0.0",
"@react-email/render": "^1.0.1",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.18",
"@swc/core": "^1.7.22",
"busboy": "^1.6.0",
"cookie-parser": "^1.4.6",
"helmet": "^7.1.0",
Expand All @@ -86,28 +86,28 @@
"@nestjs/common": "^10.4.1",
"@nestjs/core": "^10.4.1",
"@nestjs/graphql": "^12.2.0",
"@react-email/components": "^0.0.23",
"@react-email/components": "^0.0.24",
"@types/busboy": "^1.5.4",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.21",
"@types/http-errors": "^2.0.4",
"@types/node": "^22.5.0",
"@types/node": "^22.5.1",
"@types/nodemailer": "^6.4.15",
"@types/object-path": "^0.11.4",
"@types/pg": "^8.11.6",
"@types/react": "^18.3.4",
"@types/pg": "^8.11.8",
"@types/react": "^18.3.5",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"drizzle-kit": "^0.24.1",
"drizzle-kit": "^0.24.2",
"drizzle-orm": "^0.33.0",
"eslint-config-typescript-vitnode": "workspace:*",
"express": "^4.19.2",
"graphql": "^16.9.0",
"pg": "^8.12.0",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-dom": "19.0.0-rc-fb9a90fa48-20240614",
"react": "19.0.0-rc-e56f4ae3-20240830",
"react-dom": "19.0.0-rc-e56f4ae3-20240830",
"ts-node": "^10.9.2",
"tsup": "^8.2.4",
"typescript": "^5.5.4"
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/core/admin/email/send/send.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { EmailHelpersServiceType } from '@/providers/email/email-helpers.type';
import { EmailTemplateProps } from '@/providers/email/template/email-template';
import { Inject, Injectable } from '@nestjs/common';
import React from 'react';

import { MailService } from '../mail.service';

interface Args extends Pick<EmailTemplateProps, 'preview_text' | 'user'> {
from?: string;
message: JSX.Element | string;
message: React.JSX.Element | string;
subject: string;
to: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import { ArgsType, Field } from '@nestjs/graphql';
export class EditAdminAuthorizationSettingsArgs {
@Field(() => Boolean)
force_login: boolean;

@Field(() => Boolean)
lock_register: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import { Field, ObjectType } from '@nestjs/graphql';
export class ShowAdminAuthorizationSettingsObj {
@Field(() => Boolean)
force_login: boolean;

@Field(() => Boolean)
lock_register: boolean;
}
3 changes: 3 additions & 0 deletions packages/backend/src/core/middleware/show/dto/show.obj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export class SecurityCoreMiddleware {
export class AuthorizationCoreMiddleware {
@Field(() => Boolean)
force_login: boolean;

@Field(() => Boolean)
lock_register: boolean;
}

@ObjectType()
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/core/sessions/sign_up/sign_up.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CaptchaCoreCaptchaSecurityService } from '@/core/admin/security/captcha/captcha.service';
import { AccessDeniedError } from '@/errors';
import { getConfigFile } from '@/providers';
import { GqlContext } from '@/utils';
import { Injectable } from '@nestjs/common';

Expand All @@ -17,6 +19,10 @@ export class SignUpCoreSessionsService {
args: SignUpCoreSessionsArgs,
context: GqlContext,
): Promise<SignUpCoreSessionsObj> {
const config = getConfigFile();
if (config.settings.authorization.lock_register) {
throw new AccessDeniedError();
}
await this.captchaService.validateCaptcha({ req: context.req });

return this.signUpService.signUp(args, context);
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/providers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface ConfigType {
settings: {
authorization: {
force_login: boolean;
lock_register: boolean;
};
email: {
color_primary: string;
Expand Down Expand Up @@ -97,6 +98,7 @@ export const DEFAULT_CONFIG_DATA: ConfigType = {
},
authorization: {
force_login: false,
lock_register: false,
},
},
langs: [
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/providers/email/email-helpers.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UploadCoreFilesObj } from '@/core/files/helpers/upload/dto/upload.obj';
import React from 'react';

import { EmailTemplateProps } from './template/email-template';

Expand Down Expand Up @@ -26,5 +27,5 @@ export interface GetHelpersForEmailType {

export interface EmailHelpersServiceType {
getHelpersForEmail: () => GetHelpersForEmailType;
template: (props: Omit<EmailTemplateProps, 'helpers'>) => JSX.Element;
template: (props: Omit<EmailTemplateProps, 'helpers'>) => React.JSX.Element;
}
34 changes: 17 additions & 17 deletions packages/create-vitnode-app/helpers/create-packages-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export const createPackagesJSON = ({
: {},
devDependencies: {
...(eslint
? { prettier: '^3.3.3', 'prettier-plugin-tailwindcss': '^0.6.5' }
? { prettier: '^3.3.3', 'prettier-plugin-tailwindcss': '^0.6.6' }
: {}),
'eslint-config-typescript-vitnode': `^${pkg.version}`,
turbo: '^2.0.10',
typescript: '^5.4.5',
turbo: '^2.1.1',
typescript: '^5.5.4',
},
packageManager,
workspaces: ['apps/*'],
Expand All @@ -85,24 +85,24 @@ export const createPackagesJSON = ({
},
dependencies: {
geist: '^1.3.1',
'lucide-react': '^0.435.0',
next: '15.0.0-canary.110',
'lucide-react': '^0.437.0',
next: '15.0.0-canary.137',
react: '^19.0.0-rc.0',
'react-dom': '^19.0.0-rc.0',
'next-intl': '^3.17.6',
'react-hook-form': '^7.52.1',
'next-intl': '^3.19.0',
'react-hook-form': '^7.53.0',
'@hookform/resolvers': '^3.9.0',
'vitnode-frontend': `^${pkg.version}`,
},
devDependencies: {
'@types/node': '^22.5.0',
'@types/react': '^18.3.4',
'@types/node': '^22.5.1',
'@types/react': '^18.3.5',
'@types/react-dom': '^18.3.0',
autoprefixer: '^10.4.20',
'graphql-tag': '^2.12.6',
...(eslint ? { eslint: '^8.57.0' } : {}),
...(eslint ? { eslint: '^9.9.1' } : {}),
'eslint-config-typescript-vitnode': `^${pkg.version}`,
postcss: '^8.4.41',
postcss: '^8.4.42',
tailwindcss: '^3.4.10',
typescript: '^5.5.4',
},
Expand Down Expand Up @@ -132,7 +132,7 @@ export const createPackagesJSON = ({
'@nestjs/common': '^10.4.1',
'@nestjs/core': '^10.4.1',
'@nestjs/graphql': '^12.2.0',
'@react-email/components': '^0.0.23',
'@react-email/components': '^0.0.24',
'class-transformer': '^0.5.1',
'class-validator': '^0.14.1',
react: '^19.0.0-rc.0',
Expand All @@ -142,17 +142,17 @@ export const createPackagesJSON = ({
},
devDependencies: {
'@graphql-codegen/cli': '^5.0.2',
'@nestjs/cli': '^10.4.4',
'@nestjs/cli': '^10.4.5',
'@nestjs/platform-express': '^10.4.1',
'@nestjs/schematics': '^10.1.4',
'@types/express': '^4.17.21',
'@types/node': '^22.5.0',
'@types/node': '^22.5.1',
'@types/pg': '^8.11.6',
'@types/react': '^18.3.4',
'@types/react': '^18.3.5',
'cross-env': '^7.0.3',
'drizzle-kit': '^0.24.1',
'drizzle-kit': '^0.24.2',
'drizzle-orm': '^0.33.0',
...(eslint ? { eslint: '^8.57.0' } : {}),
...(eslint ? { eslint: '^9.9.1' } : {}),
'eslint-config-typescript-vitnode': `^${pkg.version}`,
pg: '^8.12.0',
'source-map-support': '^0.5.21',
Expand Down
4 changes: 2 additions & 2 deletions packages/create-vitnode-app/helpers/is-online.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync } from 'child_process';
import { lookup } from 'dns/promises';
import url from 'node:url';
import { URL } from 'url';

function getProxy(): string | undefined {
if (process.env.https_proxy) {
Expand Down Expand Up @@ -29,7 +29,7 @@ export async function getOnline(): Promise<boolean> {
return false;
}

const { hostname } = url.parse(proxy);
const { hostname } = new URL(proxy);
if (!hostname) {
// Invalid proxy URL
return false;
Expand Down
4 changes: 2 additions & 2 deletions packages/create-vitnode-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/figlet": "^1.5.8",
"@types/node": "^22.5.0",
"@types/node": "^22.5.1",
"@types/prompts": "^2.4.9",
"@types/validate-npm-package-name": "^4.0.2",
"commander": "^12.1.0",
"cross-spawn": "^7.0.3",
"eslint-config-typescript-vitnode": "workspace:*",
"ora": "^8.0.1",
"ora": "^8.1.0",
"tsup": "^8.2.4",
"typescript": "^5.5.4"
}
Expand Down
Loading

0 comments on commit 765ebb7

Please sign in to comment.