Browse Source

Merge branch 'develop' into fix/lose-admin-access

pull/2303/head
Wing-Kam Wong 2 years ago
parent
commit
f573b8c533
  1. 24
      .github/workflows/ci-cd.yml
  2. 25272
      package-lock.json
  3. 11212
      packages/nc-gui/package-lock.json
  4. 2
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts
  5. 4
      packages/nocodb/src/lib/meta/NcMetaMgr.ts
  6. 4
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasExportApis.ts
  7. 4
      packages/nocodb/src/lib/meta/api/exportApis.ts
  8. 4
      packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts
  9. 12
      packages/nocodb/src/lib/meta/api/userApi/userApis.ts
  10. 30
      packages/nocodb/src/lib/models/User.ts
  11. 1
      scripts/cypress/integration/test/explicitLogin.js

24
.github/workflows/ci-cd.yml

@ -25,7 +25,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -70,7 +70,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -115,7 +115,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -160,7 +160,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -205,7 +205,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -250,7 +250,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -295,7 +295,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -340,7 +340,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -385,7 +385,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -430,7 +430,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -475,7 +475,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -520,7 +520,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16.15.0
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:

25272
package-lock.json generated

File diff suppressed because it is too large Load Diff

11212
packages/nc-gui/package-lock.json generated

File diff suppressed because it is too large Load Diff

2
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

@ -627,7 +627,7 @@ export default async function formulaQueryBuilderv2(
} }
return query; return query;
}) })
.join()})${colAlias}` .join()})${colAlias}`.replace(/\?/g, '\\?')
); );
} else if (pt.type === 'Literal') { } else if (pt.type === 'Literal') {
return knex.raw(`?${colAlias}`, [pt.value]); return knex.raw(`?${colAlias}`, [pt.value]);

4
packages/nocodb/src/lib/meta/NcMetaMgr.ts

@ -4551,7 +4551,9 @@ export default class NcMetaMgr {
'Access-Control-Expose-Headers': 'nc-export-offset', 'Access-Control-Expose-Headers': 'nc-export-offset',
'nc-export-offset': csvData.offset, 'nc-export-offset': csvData.offset,
'nc-export-elapsed-time': csvData.elapsed, 'nc-export-elapsed-time': csvData.elapsed,
'Content-Disposition': `attachment; filename="${args.args.model_name}-export.csv"` 'Content-Disposition': `attachment; filename="${encodeURI(
args.args.model_name
)}-export.csv"`
}); });
res.send(csvData.data); res.send(csvData.data);
} }

4
packages/nocodb/src/lib/meta/api/dataApis/dataAliasExportApis.ts

@ -15,7 +15,9 @@ async function csvDataExport(req: Request, res: Response) {
'Access-Control-Expose-Headers': 'nc-export-offset', 'Access-Control-Expose-Headers': 'nc-export-offset',
'nc-export-offset': offset, 'nc-export-offset': offset,
'nc-export-elapsed-time': elapsed, 'nc-export-elapsed-time': elapsed,
'Content-Disposition': `attachment; filename="${view.title}-export.csv"` 'Content-Disposition': `attachment; filename="${encodeURI(
view.title
)}-export.csv"`
}); });
res.send(data); res.send(data);
} }

4
packages/nocodb/src/lib/meta/api/exportApis.ts

@ -11,7 +11,9 @@ async function exportCsv(req: Request, res: Response) {
'Access-Control-Expose-Headers': 'nc-export-offset', 'Access-Control-Expose-Headers': 'nc-export-offset',
'nc-export-offset': offset, 'nc-export-offset': offset,
'nc-export-elapsed-time': elapsed, 'nc-export-elapsed-time': elapsed,
'Content-Disposition': `attachment; filename="${view.title}-export.csv"` 'Content-Disposition': `attachment; filename="${encodeURI(
view.title
)}-export.csv"`
}); });
res.send(data); res.send(data);
} }

4
packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts

@ -122,7 +122,9 @@ async function exportCsv(req: Request, res: Response) {
'Access-Control-Expose-Headers': 'nc-export-offset', 'Access-Control-Expose-Headers': 'nc-export-offset',
'nc-export-offset': offset, 'nc-export-offset': offset,
'nc-export-elapsed-time': elapsed, 'nc-export-elapsed-time': elapsed,
'Content-Disposition': `attachment; filename="${view.title}-export.csv"` 'Content-Disposition': `attachment; filename="${encodeURI(
view.title
)}-export.csv"`
}); });
res.send(data); res.send(data);
} }

12
packages/nocodb/src/lib/meta/api/userApi/userApis.ts

@ -284,7 +284,8 @@ async function passwordChange(req: Request<any, any>, res): Promise<any> {
await User.update(user.id, { await User.update(user.id, {
salt, salt,
password password,
email: user.email
}); });
Audit.insert({ Audit.insert({
@ -324,12 +325,13 @@ async function passwordForgot(req: Request<any, any>, res): Promise<any> {
(req as any).ncSiteUrl (req as any).ncSiteUrl
}/api/v1/db/auth/password/reset/${token}.`, }/api/v1/db/auth/password/reset/${token}.`,
html: ejs.render(template, { html: ejs.render(template, {
resetLink: (req as any).ncSiteUrl + `/api/v1/db/auth/password/reset/${token}` resetLink:
(req as any).ncSiteUrl + `/api/v1/db/auth/password/reset/${token}`
}) })
}) })
); );
} catch (e) { } catch (e) {
console.log(e) console.log(e);
return NcError.badRequest( return NcError.badRequest(
'Email Plugin is not found. Please contact administrators to configure it in App Store first.' 'Email Plugin is not found. Please contact administrators to configure it in App Store first.'
); );
@ -343,9 +345,7 @@ async function passwordForgot(req: Request<any, any>, res): Promise<any> {
ip: (req as any).clientIp ip: (req as any).clientIp
}); });
} else { } else {
return NcError.badRequest( return NcError.badRequest('Your email has not been registered.');
'Your email has not been registered.'
);
} }
res.json({ msg: 'Please check your email to reset the password' }); res.json({ msg: 'Please check your email to reset the password' });
} }

30
packages/nocodb/src/lib/models/User.ts

@ -74,23 +74,23 @@ export default class User implements UserType {
'roles' 'roles'
]); ]);
// get existing cache // get existing cache
let key = `${CacheScope.USER}:${id}`; const keys = [
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); // update user:<id>
if (o) { `${CacheScope.USER}:${id}`,
o = { ...o, ...updateObj }; // update user:<email>
// set cache `${CacheScope.USER}:${user.email}`
await NocoCache.set(key, o); ];
{ for (const key of keys) {
// update user:<email> let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
key = `${CacheScope.USER}:${o.email}`; if (o) {
o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); o = { ...o, ...updateObj };
if (o) { // set cache
o = { ...o, ...updateObj }; await NocoCache.set(key, o);
// set cache
await NocoCache.set(key, o);
}
} }
} }
// as <projectId> is unknown, delete user:<email>___<projectId> in cache
await NocoCache.delAll(CacheScope.USER, `${user.email}___*`);
// set meta // set meta
return await ncMeta.metaUpdate(null, null, MetaTable.USERS, updateObj, id); return await ncMeta.metaUpdate(null, null, MetaTable.USERS, updateObj, id);
} }

1
scripts/cypress/integration/test/explicitLogin.js

@ -10,7 +10,6 @@ export const genTest = (apiType, dbType) => {
before(() => { before(() => {
// loginPage.loginAndOpenProject(apiType, dbType); // loginPage.loginAndOpenProject(apiType, dbType);
// open a table to work on views // open a table to work on views
//
// cy.openTableTab('City'); // cy.openTableTab('City');
}); });

Loading…
Cancel
Save