diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell.vue index 2d789dd9c5..2a389279aa 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell.vue @@ -18,6 +18,7 @@ :required="required" :is-public="isPublic" :metas="metas" + :password="password" v-on="$listeners" /> @@ -128,7 +129,8 @@ export default { isNew: Boolean, disabledColumns: Object, isPublic: Boolean, - metas: Object + metas: Object, + password: String }, data: () => ({ newRecordModal: false, diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue index 468a8a3d93..cce006f119 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/components/listItems.vue @@ -109,7 +109,8 @@ export default { mm: [Object, Function], parentId: [String, Number], parentMeta: [Object], - isPublic: Boolean + isPublic: Boolean, + password: String }, data: () => ({ data: null, diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue index a3480b2f6d..b6befd6e81 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -57,6 +57,7 @@ where: isNew ? null :`~not(${childForeignKey},eq,${parentId})~or(${childForeignKey},is,null)`, }" :is-public="isPublic" + :password="password" @add-new-record="insertAndAddNewChildRecord" @add="addChildToParent" /> @@ -172,7 +173,8 @@ export default { isForm: Boolean, required: Boolean, isPublic: Boolean, - metas: Object + metas: Object, + password: String }, data: () => ({ newRecordModal: false, diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue index 53375a3c76..1d04ec4a57 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue @@ -49,6 +49,7 @@ :parent-id="row && row[parentPrimaryKey]" :is-public="isPublic" :query-params="childQueryParams" + :password="password" @add-new-record="insertAndAddNewChildRecord" @add="addChildToParent" /> @@ -152,7 +153,8 @@ export default { isForm: Boolean, required: Boolean, isPublic: Boolean, - metas: Object + metas: Object, + password: String }, data: () => ({ isNewChild: false, diff --git a/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue b/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue index cd955eba63..cf2091a58c 100644 --- a/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue +++ b/packages/nc-gui/components/project/spreadsheet/public/xcForm.vue @@ -119,6 +119,7 @@ :hint="localParams.fields[col.alias].description" :required="localParams.fields[col.alias].description" :metas="metas" + :password="password" @update:localState="state => $set(virtual,col._cn, state)" @updateCol="updateCol" /> @@ -197,6 +198,28 @@ + + + + + + +
+ + Unlock + +
+
+
+
@@ -219,6 +242,7 @@ export default { return { active: null, loading: false, + showPasswordModal: false, submitting: false, submitted: false, client: null, @@ -321,7 +345,7 @@ export default { } catch (e) { if (e.message === 'Not found') { this.notFound = true - } else { + } else if (e.message === 'Invalid password') { this.showPasswordModal = true } } diff --git a/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts b/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts index 6a02f265cf..d9db436701 100644 --- a/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts +++ b/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts @@ -44,18 +44,19 @@ const NOCO_RELEASE = 'NOCO_RELEASE'; export default class NcMetaMgr { public projectConfigs = {}; - public readonly pluginMgr: NcPluginMgr; public twilioInstance: Twilio; protected app: Noco; + protected config: NcConfig; protected listener: (data) => Promise; protected xcMeta: NcMetaIO; protected projectMgr: any; // @ts-ignore protected isEe = false; + protected readonly INVALID_PASSWORD_ERROR = 'Invalid password'; constructor(app: Noco, config: NcConfig, xcMeta: NcMetaIO) { this.app = app; @@ -3452,6 +3453,14 @@ export default class NcMetaMgr { throw new Error('Not found'); } + if ( + viewMeta && + viewMeta.password && + viewMeta.password !== args.args.password + ) { + throw new Error(this.INVALID_PASSWORD_ERROR); + } + const tn = args.args?.tn; // @ts-ignore @@ -3504,6 +3513,18 @@ export default class NcMetaMgr { }) .first(); + if (!viewMeta) { + throw new Error('Not found'); + } + + if ( + viewMeta && + viewMeta.password && + viewMeta.password !== args.args.password + ) { + throw new Error(this.INVALID_PASSWORD_ERROR); + } + const queryParams = JSON.parse(viewMeta.query_params); // const meta = JSON.parse(viewMeta.meta); @@ -3548,6 +3569,14 @@ export default class NcMetaMgr { throw new Error('Not found'); } + if ( + viewMeta && + viewMeta.password && + viewMeta.password !== args.args.password + ) { + throw new Error(this.INVALID_PASSWORD_ERROR); + } + // todo : filter out columns of related table try { const apiBuilder = this.app?.projectBuilders diff --git a/packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts b/packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts index 8ad861d9c3..eaf876e561 100644 --- a/packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts +++ b/packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts @@ -127,7 +127,7 @@ export default class NcMetaMgrEE extends NcMetaMgr { viewMeta.password && viewMeta.password !== args.args.password ) { - throw new Error('Invalid password'); + throw new Error(this.INVALID_PASSWORD_ERROR); } const apiBuilder = this.app?.projectBuilders