Browse Source

Merge pull request #7044 from nocodb/fix/4330-hide-signup-link

Remove signup link from signup page if invite only signup enabled
nc-oss/44517c26
Raju Udava 12 months ago committed by GitHub
parent
commit
0384ec5b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 32
      packages/nocodb/src/models/Store.ts
  5. 11
      packages/nocodb/src/services/utils.service.ts
  6. 1
      packages/nocodb/src/utils/globals.ts

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

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

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

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

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

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

32
packages/nocodb/src/models/Store.ts

@ -2,7 +2,8 @@ import type { SortType } from 'nocodb-sdk';
import { NcError } from '~/helpers/catchError';
import { extractProps } from '~/helpers/extractProps';
import Noco from '~/Noco';
import { MetaTable } from '~/utils/globals';
import { CacheGetType, CacheScope, MetaTable } from '~/utils/globals';
import NocoCache from '~/cache/NocoCache';
// Store is used for storing key value pairs
export default class Store {
@ -18,8 +19,30 @@ export default class Store {
Object.assign(this, data);
}
public static get(key: string, ncMeta = Noco.ncMeta): Promise<Store> {
return ncMeta.metaGet(null, null, MetaTable.STORE, { key });
public static async get(
key: string,
lookInCache = false,
ncMeta = Noco.ncMeta,
): Promise<Store> {
// get from cache if lookInCache is true
if (lookInCache) {
const storeData =
key &&
(await NocoCache.get(
`${CacheScope.STORE}:${key}`,
CacheGetType.TYPE_OBJECT,
));
if (storeData) return storeData;
}
const storeData = await ncMeta.metaGet(null, null, MetaTable.STORE, {
key,
});
if (lookInCache)
await NocoCache.set(`${CacheScope.STORE}:${key}`, storeData);
return storeData;
}
static async saveOrUpdate(store: Store, ncMeta = Noco.ncMeta) {
@ -35,7 +58,7 @@ export default class Store {
'tag',
]);
const existing = await Store.get(store.key, ncMeta);
const existing = await Store.get(store.key,false, ncMeta);
if (existing) {
await ncMeta.metaUpdate(null, null, MetaTable.STORE, insertObj, {
key: store.key,
@ -43,5 +66,6 @@ export default class Store {
} else {
await ncMeta.metaInsert(null, null, MetaTable.STORE, insertObj);
}
if (store.key) await NocoCache.del(`${CacheScope.STORE}:${store.key}`);
}
}

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

@ -5,10 +5,10 @@ import { ViewTypes } from 'nocodb-sdk';
import { ConfigService } from '@nestjs/config';
import { useAgent } from 'request-filtering-agent';
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 { NcError } from '~/helpers/catchError';
import { Base, User } from '~/models';
import { Base, Store, User } from '~/models';
import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { MetaTable } from '~/utils/globals';
@ -365,6 +365,12 @@ export class UtilsService {
async appInfo(param: { req: { ncSiteUrl: string } }) {
const baseHasAdmin = !(await User.isFirst());
let settings: { invite_only_signup?: boolean } = {};
try {
settings = JSON.parse((await Store.get(NC_APP_SETTINGS, true))?.value);
} catch {}
const oidcAuthEnabled = !!(
process.env.NC_OIDC_ISSUER &&
process.env.NC_OIDC_AUTHORIZATION_URL &&
@ -415,6 +421,7 @@ export class UtilsService {
}),
mainSubDomain: this.configService.get('mainSubDomain', { infer: true }),
dashboardPath: this.configService.get('dashboardPath', { infer: true }),
inviteOnlySignup: settings.invite_only_signup,
};
return result;

1
packages/nocodb/src/utils/globals.ts

@ -158,6 +158,7 @@ export enum CacheScope {
SINGLE_QUERY = 'singleQuery',
JOBS = 'nc_jobs',
PRESIGNED_URL = 'presignedUrl',
STORE = 'presignedUrl',
}
export enum CacheGetType {

Loading…
Cancel
Save