Browse Source

feat: remove signup link from signup page if invite only signup enabled

pull/7044/head
Pranav C 1 year ago
parent
commit
4f0f38d953
  1. 1
      packages/nc-gui/composables/useGlobal/state.ts
  2. 1
      packages/nc-gui/composables/useGlobal/types.ts
  3. 2
      packages/nc-gui/pages/signin.vue
  4. 26
      packages/nocodb/src/services/utils.service.ts

1
packages/nc-gui/composables/useGlobal/state.ts

@ -109,6 +109,7 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
automationLogLevel: 'OFF', automationLogLevel: 'OFF',
disableEmailAuth: false, disableEmailAuth: false,
dashboardPath: '/dashboard', dashboardPath: '/dashboard',
inviteOnlySignup: false,
}) })
/** reactive token payload */ /** reactive token payload */

1
packages/nc-gui/composables/useGlobal/types.ts

@ -34,6 +34,7 @@ export interface AppInfo {
disableEmailAuth: boolean disableEmailAuth: boolean
mainSubDomain?: string mainSubDomain?: string
dashboardPath: string dashboardPath: string
inviteOnlySignup: boolean
} }
export interface StoredState { export interface StoredState {

2
packages/nc-gui/pages/signin.vue

@ -184,7 +184,7 @@ function navigateForgotPassword() {
</a> </a>
</div> </div>
<div class="text-end prose-sm"> <div class="text-end prose-sm" v-if="!appInfo.inviteOnlySignup">
{{ $t('msg.info.signUp.dontHaveAccount') }} {{ $t('msg.info.signUp.dontHaveAccount') }}
<nuxt-link @click="navigateSignUp">{{ $t('general.signUp') }}</nuxt-link> <nuxt-link @click="navigateSignUp">{{ $t('general.signUp') }}</nuxt-link>
</div> </div>

26
packages/nocodb/src/services/utils.service.ts

@ -5,10 +5,10 @@ import { ViewTypes } from 'nocodb-sdk';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { useAgent } from 'request-filtering-agent'; import { useAgent } from 'request-filtering-agent';
import type { AppConfig } from '~/interface/config'; import type { AppConfig } from '~/interface/config';
import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants'; import {NC_APP_SETTINGS, NC_ATTACHMENT_FIELD_SIZE} from '~/constants';
import SqlMgrv2 from '~/db/sql-mgr/v2/SqlMgrv2'; import SqlMgrv2 from '~/db/sql-mgr/v2/SqlMgrv2';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { Base, User } from '~/models'; import {Base, Store, User} from '~/models';
import Noco from '~/Noco'; import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
@ -365,6 +365,13 @@ export class UtilsService {
async appInfo(param: { req: { ncSiteUrl: string } }) { async appInfo(param: { req: { ncSiteUrl: string } }) {
const baseHasAdmin = !(await User.isFirst()); const baseHasAdmin = !(await User.isFirst());
let settings: { invite_only_signup?: boolean } = {};
try {
settings = JSON.parse((await Store.get(NC_APP_SETTINGS))?.value);
} catch {}
const oidcAuthEnabled = !!( const oidcAuthEnabled = !!(
process.env.NC_OIDC_ISSUER && process.env.NC_OIDC_ISSUER &&
process.env.NC_OIDC_AUTHORIZATION_URL && process.env.NC_OIDC_AUTHORIZATION_URL &&
@ -384,10 +391,10 @@ export class UtilsService {
type: 'rest', type: 'rest',
env: process.env.NODE_ENV, env: process.env.NODE_ENV,
googleAuthEnabled: !!( googleAuthEnabled: !!(
process.env.NC_GOOGLE_CLIENT_ID && process.env.NC_GOOGLE_CLIENT_SECRET process.env.NC_GOOGLE_CLIENT_ID && process.env.NC_GOOGLE_CLIENT_SECRET
), ),
githubAuthEnabled: !!( githubAuthEnabled: !!(
process.env.NC_GITHUB_CLIENT_ID && process.env.NC_GITHUB_CLIENT_SECRET process.env.NC_GITHUB_CLIENT_ID && process.env.NC_GITHUB_CLIENT_SECRET
), ),
oidcAuthEnabled, oidcAuthEnabled,
oidcProviderName, oidcProviderName,
@ -395,8 +402,8 @@ export class UtilsService {
connectToExternalDB: !process.env.NC_CONNECT_TO_EXTERNAL_DB_DISABLED, connectToExternalDB: !process.env.NC_CONNECT_TO_EXTERNAL_DB_DISABLED,
version: packageVersion, version: packageVersion,
defaultLimit: Math.max( defaultLimit: Math.max(
Math.min(defaultLimitConfig.limitDefault, defaultLimitConfig.limitMax), Math.min(defaultLimitConfig.limitDefault, defaultLimitConfig.limitMax),
defaultLimitConfig.limitMin, defaultLimitConfig.limitMin,
), ),
defaultGroupByLimit: defaultGroupByLimitConfig, defaultGroupByLimit: defaultGroupByLimitConfig,
timezone: defaultConnectionConfig.timezone, timezone: defaultConnectionConfig.timezone,
@ -413,9 +420,10 @@ export class UtilsService {
disableEmailAuth: this.configService.get('auth.disableEmailAuth', { disableEmailAuth: this.configService.get('auth.disableEmailAuth', {
infer: true, infer: true,
}), }),
mainSubDomain: this.configService.get('mainSubDomain', { infer: true }), mainSubDomain: this.configService.get('mainSubDomain', {infer: true}),
dashboardPath: this.configService.get('dashboardPath', { infer: true }), dashboardPath: this.configService.get('dashboardPath', {infer: true}),
}; inviteOnlySignup: settings.invite_only_signup,
}
return result; return result;
} }

Loading…
Cancel
Save