From 3d9125f971b68bf976b293ed66e213acf3bbbc60 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 16 Apr 2022 15:18:38 +0530 Subject: [PATCH 1/6] fix: allow hmList permission for commenter/viewer role re #1693 Signed-off-by: Pranav C --- packages/nc-gui/plugins/tele.js | 20 +++++++++---------- packages/nocodb/package-lock.json | 14 ++++++------- packages/nocodb/package.json | 4 ++-- .../nocodb/src/lib/noco/meta/api/index.ts | 15 ++++++++++++-- packages/nocodb/src/lib/utils/projectAcl.ts | 1 + 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/packages/nc-gui/plugins/tele.js b/packages/nc-gui/plugins/tele.js index e7abe4ffb7..1d2088b26d 100644 --- a/packages/nc-gui/plugins/tele.js +++ b/packages/nc-gui/plugins/tele.js @@ -23,7 +23,8 @@ export default function({ socket.disconnect() socket = null }) - } catch { } + } catch { + } } app.router.onReady(() => { @@ -32,13 +33,11 @@ export default function({ return } socket.emit('page', { - id: store.state.users.user && store.state.users.user.id, path: to.matched[0].path + (to.query && to.query.type ? `?type=${to.query.type}` : '') }) }) if (socket) { socket.emit('page', { - id: store.state.users.user && store.state.users.user.id, path: route.matched[0].path + (route.query && route.query.type ? `?type=${route.query.type}` : '') }) } @@ -49,9 +48,8 @@ export default function({ if (socket) { socket.emit('event', { event: evt, - id: store.state.users.user && store.state.users.user.id, ...(data || {}), - $current_url: gatPath(app) + path: gatPath(app) }) } } @@ -61,14 +59,14 @@ export default function({ function getListener(binding) { return function(e) { - if (!socket) { return } - const cat = window.location.hash.replace(/\d+\/(?=dashboard)/, '') + if (!socket) { + return + } const event = binding.value && binding.value[0] const data = binding.value && binding.value[1] const extra = binding.value && binding.value.slice(2) tele.emit(event, { - cat, data, extra }) @@ -87,14 +85,16 @@ export default function({ store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => { if (token) { - init(token).then(() => {}) + init(token).then(() => { + }) } else if (socket) { socket.disconnect() socket = null } }) if (store.state.project.projectInfo && store.state.project.projectInfo.teleEnabled && store.state.users.token) { - init(store.state.users.token).then(() => {}) + init(store.state.users.token).then(() => { + }) } } diff --git a/packages/nocodb/package-lock.json b/packages/nocodb/package-lock.json index 80c1fde157..a5369baef6 100644 --- a/packages/nocodb/package-lock.json +++ b/packages/nocodb/package-lock.json @@ -68,7 +68,7 @@ "mysql2": "^2.2.5", "nanoid": "^3.1.20", "nc-common": "0.0.6", - "nc-help": "^0.2.31", + "nc-help": "^0.2.44", "nc-lib-gui": "0.84.15", "nc-plugin": "^0.1.1", "ncp": "^2.0.0", @@ -16034,9 +16034,9 @@ } }, "node_modules/nc-help": { - "version": "0.2.42", - "resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.42.tgz", - "integrity": "sha512-qRQ9ijK3K5HfEp4LUJekk/EerNAa4YgM+jRtNLL1RMv+4IPAMO6NsXvdxNOW6h3robdY+xcWuaNqekXqGn1FXA==", + "version": "0.2.44", + "resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.44.tgz", + "integrity": "sha512-AAcMIh2Nhzm7iFQSaTOu27W4KU5eOAbPrGQLND+VAmdQurXACuHMCN6y7IZR3cPZMM1H7GQ0JmxVYzZ+S49MzQ==", "dependencies": { "axios": "^0.21.1", "boxen": "^4.2.0", @@ -37473,9 +37473,9 @@ "integrity": "sha512-3AryS9uwa5NfISLxMciUonrH7YfXp+nlahB9T7girXIsLQrmwX4MdnuKs32akduCOGpKmjTJSWmATULbuMkbfw==" }, "nc-help": { - "version": "0.2.42", - "resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.42.tgz", - "integrity": "sha512-qRQ9ijK3K5HfEp4LUJekk/EerNAa4YgM+jRtNLL1RMv+4IPAMO6NsXvdxNOW6h3robdY+xcWuaNqekXqGn1FXA==", + "version": "0.2.44", + "resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.44.tgz", + "integrity": "sha512-AAcMIh2Nhzm7iFQSaTOu27W4KU5eOAbPrGQLND+VAmdQurXACuHMCN6y7IZR3cPZMM1H7GQ0JmxVYzZ+S49MzQ==", "requires": { "axios": "^0.21.1", "boxen": "^4.2.0", diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index 97dda45b4a..592e854947 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -67,7 +67,7 @@ "help:c": "ts-node ./help/a", "watch:build": "nodemon -e ts,js -w ./src -x npm run build", "watch:serve": "nodemon -e ts -w ./build -x npm run debug-local ", - "watch:run": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/docker --log-error --project tsconfig.json\"", + "watch:run": "cross-env NC_DISABLE_TELE1=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/docker --log-error --project tsconfig.json\"", "watch:run:cypress": "cross-env EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/docker --log-error --project tsconfig.json\"", "watch:run:mysql": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/dockerRunMysql --log-error --project tsconfig.json\"", "run": "ts-node src/example/docker", @@ -150,7 +150,7 @@ "mysql2": "^2.2.5", "nanoid": "^3.1.20", "nc-common": "0.0.6", - "nc-help": "^0.2.31", + "nc-help": "^0.2.44", "nc-lib-gui": "0.84.15", "nc-plugin": "^0.1.1", "ncp": "^2.0.0", diff --git a/packages/nocodb/src/lib/noco/meta/api/index.ts b/packages/nocodb/src/lib/noco/meta/api/index.ts index 3f72fdaa41..6c6f904b37 100644 --- a/packages/nocodb/src/lib/noco/meta/api/index.ts +++ b/packages/nocodb/src/lib/noco/meta/api/index.ts @@ -44,6 +44,8 @@ import { Tele } from 'nc-help'; import { Server } from 'socket.io'; import passport from 'passport'; +import crypto from 'crypto'; + export default function(router: Router, server) { initStrategies(router); projectApis(router); @@ -106,11 +108,20 @@ export default function(router: Router, server) { } )(socket.handshake, {}, next); }).on('connection', socket => { + const id = getHash(Tele.id + (socket?.handshake as any)?.user?.id); + socket.on('page', args => { - Tele.page(args); + Tele.page({ ...args, id }); }); socket.on('event', args => { - Tele.event(args); + Tele.event({ ...args, id }); }); }); } + +function getHash(str) { + return crypto + .createHash('md5') + .update(str) + .digest('hex'); +} diff --git a/packages/nocodb/src/lib/utils/projectAcl.ts b/packages/nocodb/src/lib/utils/projectAcl.ts index 3313b62fcc..f6b0251872 100644 --- a/packages/nocodb/src/lib/utils/projectAcl.ts +++ b/packages/nocodb/src/lib/utils/projectAcl.ts @@ -139,6 +139,7 @@ export default { columnList: true, mmList: true, + hmList: true, commentList: true, commentRow: true, From 5a86140d0c3d7b195e6f09b6b5e1c72292ef0f39 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 16 Apr 2022 15:19:58 +0530 Subject: [PATCH 2/6] fix: allow projectInfoGet permission for commenter/viewer role re #1694 Signed-off-by: Pranav C --- packages/nocodb/src/lib/utils/projectAcl.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/nocodb/src/lib/utils/projectAcl.ts b/packages/nocodb/src/lib/utils/projectAcl.ts index f6b0251872..59e15758b2 100644 --- a/packages/nocodb/src/lib/utils/projectAcl.ts +++ b/packages/nocodb/src/lib/utils/projectAcl.ts @@ -142,6 +142,7 @@ export default { hmList: true, commentList: true, commentRow: true, + projectInfoGet: true, // data dataList: true, @@ -185,6 +186,7 @@ export default { // sort & filter sortList: true, + projectInfoGet: true, mmList: true, hmList: true, From b1fba037dfef18648c2ce50b96f0bd96cda2d202 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 16 Apr 2022 15:29:50 +0530 Subject: [PATCH 3/6] fix: update hasmany record unlink method with new sdk functions re #1695 Signed-off-by: Pranav C --- .../spreadsheet/components/virtualCell/hasManyCell.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 71fe16590c..c63bf7710a 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -342,11 +342,13 @@ export default { return } const id = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') - await this.$api.data.nestedDelete( - this.meta.id, + await this.$api.dbTableRow.nestedDelete( + 'noco', + this.projectName, + this.meta.title, this.parentId, - this.column.id, - 'hm', + RelationTypes.HAS_MANY, + this.column.title, id ) From 3bb41d7ba0cf7a70223ed1614ee0f9fcfa7ebeec Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 16 Apr 2022 15:38:50 +0530 Subject: [PATCH 4/6] fix: save relation column data fro newly created row by using `nestedAdd` method re #1696 Signed-off-by: Pranav C --- .../components/virtualCell/hasManyCell.vue | 17 ++++++++++------- .../components/virtualCell/manyToManyCell.vue | 16 +++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) 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 c63bf7710a..d778016cb4 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -442,15 +442,18 @@ export default { // eslint-disable-next-line no-cond-assign while (child = this.localState.pop()) { if (row) { - // todo: use common method const pid = this.meta.columns.filter(c => c.pk).map(c => row[c.title]).join('___') const id = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') - const title = this.childForeignKey - await this.childApi.update(id, { - [title]: parseIfInteger(pid) - }, { - [title]: child[this.childForeignKey] - }) + + await this.$api.dbTableRow.nestedAdd( + 'noco', + this.projectName, + this.meta.title, + pid, + 'hm', + this.column.title, + id + ) } else { await this.addChildToParent(child) } 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 dfd5bf4d8b..7a317b99e6 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue @@ -461,16 +461,18 @@ export default { // eslint-disable-next-line no-cond-assign while (child = this.localState.pop()) { if (row) { - // todo: use common method const cid = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') const pid = this.meta.columns.filter(c => c.pk).map(c => row[c.title]).join('___') - const vcidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_parent_column_id).title - const vpidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_child_column_id).title - await this.assocApi.insert({ - [vcidCol]: parseIfInteger(cid), - [vpidCol]: parseIfInteger(pid) - }) + await this.$api.dbTableRow.nestedAdd( + 'noco', + this.projectName, + this.meta.title, + pid, + 'mm', + this.column.title, + cid + ) } else { await this.addChildToParent(child) } From 3c745fc6757ff73dde8ad51b3066e2c23911bde5 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 16 Apr 2022 15:48:56 +0530 Subject: [PATCH 5/6] refactor: replace nestedDelete with nestedRemove Signed-off-by: Pranav C --- .../components/virtualCell/belongsToCell.vue | 2 +- .../components/virtualCell/hasManyCell.vue | 2 +- .../components/virtualCell/manyToManyCell.vue | 2 +- packages/nocodb-sdk/src/lib/Api.ts | 42 ++-- scripts/sdk/swagger.json | 208 ++++++++++++++++-- 5 files changed, 214 insertions(+), 42 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue index 39eb7a4ac9..1f4c7fcd74 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/belongsToCell.vue @@ -281,7 +281,7 @@ export default { const id = this.meta.columns.filter(c => c.pk).map(c => this.row[c.title]).join('___') // todo: audit - await this.$api.dbTableRow.nestedDelete( + await this.$api.dbTableRow.nestedRemove( 'noco', this.projectName, this.meta.title, 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 d778016cb4..287ce0e566 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/hasManyCell.vue @@ -342,7 +342,7 @@ export default { return } const id = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') - await this.$api.dbTableRow.nestedDelete( + await this.$api.dbTableRow.nestedRemove( 'noco', this.projectName, this.meta.title, 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 7a317b99e6..9ada97bc6a 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/manyToManyCell.vue @@ -318,7 +318,7 @@ export default { const cid = this.childMeta.columns.filter(c => c.pk).map(c => child[c.title]).join('___') const pid = this.meta.columns.filter(c => c.pk).map(c => this.row[c.title]).join('___') - await this.$api.dbTableRow.nestedDelete( + await this.$api.dbTableRow.nestedRemove( 'noco', this.projectName, this.meta.title, diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index f7f0d2df31..a36717bc63 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -620,6 +620,15 @@ export type ColumnReqType = } | { uidt?: string; formula_raw?: string; formula?: string; title?: string }; +export interface UserInfoType { + id?: string; + email?: string; + email_verified?: string; + firstname?: string; + lastname?: string; + roles?: any; +} + import axios, { AxiosInstance, AxiosRequestConfig, ResponseType } from 'axios'; export type QueryParamsType = Record; @@ -798,7 +807,7 @@ export class Api< * @summary Signup * @request POST:/api/v1/db/auth/user/signup * @response `200` `{ token?: string }` OK - * @response `400` `void` Bad Request + * @response `400` `{ msg?: string }` Bad Request * @response `401` `void` Unauthorized * @response `403` `void` Forbidden */ @@ -806,7 +815,7 @@ export class Api< data: { email?: string; password?: string }, params: RequestParams = {} ) => - this.request<{ token?: string }, void>({ + this.request<{ token?: string }, { msg?: string } | void>({ path: `/api/v1/db/auth/user/signup`, method: 'POST', body: data, @@ -822,12 +831,13 @@ export class Api< * @summary Signin * @request POST:/api/v1/db/auth/user/signin * @response `200` `{ token?: string }` OK + * @response `400` `{ msg?: string }` Bad Request */ signin: ( data: { email: string; password: string }, params: RequestParams = {} ) => - this.request<{ token?: string }, any>({ + this.request<{ token?: string }, { msg?: string }>({ path: `/api/v1/db/auth/user/signin`, method: 'POST', body: data, @@ -843,12 +853,13 @@ export class Api< * @name Me * @summary User Info * @request GET:/api/v1/db/auth/user/me - * @response `200` `UserType` OK + * @response `200` `UserInfoType` OK */ - me: (params: RequestParams = {}) => - this.request({ + me: (query?: { project_id?: string }, params: RequestParams = {}) => + this.request({ path: `/api/v1/db/auth/user/me`, method: 'GET', + query: query, format: 'json', ...params, }), @@ -861,9 +872,10 @@ export class Api< * @summary Password Forgot * @request POST:/api/v1/db/auth/password/forgot * @response `200` `void` OK + * @response `401` `void` Unauthorized */ passwordForgot: (data: { email?: string }, params: RequestParams = {}) => - this.request({ + this.request({ path: `/api/v1/db/auth/password/forgot`, method: 'POST', body: data, @@ -878,21 +890,19 @@ export class Api< * @name PasswordChange * @summary Password Change * @request POST:/api/v1/db/auth/password/change - * @response `200` `void` OK + * @response `200` `{ msg?: string }` OK + * @response `400` `{ msg?: string }` Bad request */ passwordChange: ( - data: { - currentPassword?: string; - newPassword?: string; - verifyPassword?: string; - }, + data: { currentPassword?: string; newPassword?: string }, params: RequestParams = {} ) => - this.request({ + this.request<{ msg?: string }, { msg?: string }>({ path: `/api/v1/db/auth/password/change`, method: 'POST', body: data, type: ContentType.Json, + format: 'json', ...params, }), @@ -2466,11 +2476,11 @@ export class Api< * No description * * @tags DB table row - * @name NestedDelete + * @name NestedRemove * @request DELETE:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}/{relationType}/{columnName}/{refRowId} * @response `200` `any` OK */ - nestedDelete: ( + nestedRemove: ( orgs: string, projectName: string, tableName: string, diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 1188a262ce..fb8532e655 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -26,12 +26,58 @@ "type": "string" } } + }, + "examples": { + "Successful registration response": { + "value": { + "token": "string" + } + } } } } }, "400": { - "description": "Bad Request" + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + }, + "examples": { + "Invalid email": { + "value": { + "msg": "Invalid email" + } + }, + "Invalid invite url": { + "value": { + "msg": "Invalid invite url" + } + }, + "Expired invite url": { + "value": { + "msg": "Expired invite url, Please contact super admin to get a new invite url" + } + }, + "User already exist": { + "value": { + "msg": "User already exist" + } + }, + "Invite only signup": { + "value": { + "msg": "Not allowed to signup, contact super admin" + } + } + } + } + } }, "401": { "description": "Unauthorized" @@ -68,6 +114,21 @@ } } } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + } + } } }, "tags": [ @@ -90,6 +151,14 @@ "email", "password" ] + }, + "examples": { + "example-1": { + "value": { + "email": "user@nocodb.com", + "password": "Password" + } + } } } } @@ -109,7 +178,21 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/User" + "$ref": "#/components/schemas/UserInfo" + }, + "examples": { + "example-1": { + "value": { + "id": "string", + "email": "string", + "email_verified": "string", + "firstname": "string", + "lastname": "string", + "roles": { + "editor": true + } + } + } } } } @@ -118,7 +201,17 @@ "tags": [ "Auth" ], - "description": "Returns authenticated user info" + "description": "Returns authenticated user info", + "parameters": [ + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "project_id", + "description": "Pass project id to get project specific roles along with user info" + } + ] } }, "/api/v1/db/auth/password/forgot": { @@ -128,6 +221,9 @@ "responses": { "200": { "description": "OK" + }, + "401": { + "description": "Unauthorized" } }, "description": "Emails user with a reset url.", @@ -146,7 +242,8 @@ } } } - } + }, + "description": "Pass registered user email id in request body" } }, "parameters": [] @@ -157,7 +254,53 @@ "operationId": "auth-password-change", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + }, + "examples": { + "Success response": { + "value": { + "msg": "Password updated successfully" + } + } + } + } + } + }, + "400": { + "description": "Bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + }, + "examples": { + "Missing params": { + "value": { + "msg": "Missing new/old password" + } + }, + "Wrong password": { + "value": { + "msg": "Current password is wrong" + } + } + } + } + } } }, "description": "Change password of authenticated user with a new one.", @@ -175,14 +318,20 @@ }, "newPassword": { "type": "string" - }, - "verifyPassword": { - "type": "string" + } + } + }, + "examples": { + "example-1": { + "value": { + "currentPassword": "string", + "newPassword": "string" } } } } - } + }, + "description": "Old password need to be passed along with new password for changing password." } }, "parameters": [] @@ -292,7 +441,6 @@ }, "parameters": [] }, - "/api/v1/db/meta/projects/{projectId}/users": { "get": { "summary": "Project Users", @@ -1522,8 +1670,7 @@ "get": { "summary": "", "operationId": "db-view-column-list", - "responses": { - }, + "responses": {}, "tags": [ "DB View Column" ] @@ -2281,7 +2428,6 @@ } } }, - "/api/v1/db/data/{orgs}/{projectName}/{tableName}": { "parameters": [ { @@ -3104,7 +3250,8 @@ "name": "relationType", "in": "path", "required": true - },{ + }, + { "schema": { "type": "string" }, @@ -3245,7 +3392,7 @@ }, "delete": { "summary": "", - "operationId": "db-table-row-nested-delete", + "operationId": "db-table-row-nested-remove", "responses": { "200": { "description": "OK", @@ -3350,7 +3497,6 @@ ] } }, - "/api/v1/db/public/shared-view/{sharedViewUuid}/rows": { "parameters": [ { @@ -3421,7 +3567,7 @@ "multipart/form-data": { "schema": { "type": "object", - "properties": { } + "properties": {} } } } @@ -3707,7 +3853,6 @@ ] } }, - "/api/v1/db/meta/audits/comments": { "parameters": [], "get": { @@ -3945,7 +4090,6 @@ } } }, - "/api/v1/db/meta/tables/{tableId}/hooks": { "parameters": [ { @@ -4195,7 +4339,6 @@ ] } }, - "/api/v1/db/meta/plugins": { "parameters": [], "get": { @@ -4374,7 +4517,6 @@ ] } }, - "/api/v1/db/meta/connection/test": { "parameters": [], "post": { @@ -4480,7 +4622,6 @@ }, "parameters": [] }, - "/api/v1/db/meta/projects/{projectId}/api-tokens": { "get": { "summary": "Your GET endpoint", @@ -4583,7 +4724,6 @@ } ] }, - "/api/v1/db/storage/upload": { "post": { "summary": "Attachment", @@ -7031,6 +7171,28 @@ ], "description": "", "type": "object" + }, + "UserInfo": { + "title": "UserInfo", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "email": { + "type": "string" + }, + "email_verified": { + "type": "string" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "roles": {} + } } }, "requestBodies": { From 5b7c12023d00ae5347965ea96ddabf388801eadb Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 16 Apr 2022 16:17:02 +0530 Subject: [PATCH 6/6] fix: user info api call correction Signed-off-by: Pranav C --- packages/nc-gui/store/users.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/store/users.js b/packages/nc-gui/store/users.js index b153653d7a..cb0693b66d 100644 --- a/packages/nc-gui/store/users.js +++ b/packages/nc-gui/store/users.js @@ -153,7 +153,7 @@ export const actions = { setInterval(async() => { if (getters.GtrUser) { try { - const res = await this.$api.auth.me() // this.$axios.get('/user/me') + const res = await this.$api.auth.me() if (res === null || !res.email) { commit('MutSetUser', null) } else { @@ -239,7 +239,6 @@ export const actions = { // console.log('in action signin'); let err = null try { - const userPromise = await this.$api.auth.signin(data) commit('MutSetToken', userPromise.token) @@ -272,7 +271,7 @@ export const actions = { async ActGetUserDetails({ commit, state }) { try { - const user = await this.$api.auth.me({ // await this.$axios.get('/user/me', { + const user = await this.$api.auth.me({}, { headers: { 'xc-auth': state.token } @@ -285,11 +284,10 @@ export const actions = { async ActGetProjectUserDetails({ commit, state }, projectId) { try { - const user = await this.$api.auth.me({ // '/user/me?project_id=' + projectId, { + const user = await this.$api.auth.me({ project_id: projectId }, { headers: { 'xc-auth': state.token - }, - query: { project_id: projectId } + } }) commit('MutProjectRole', user && user.roles) } catch (e) { @@ -299,7 +297,7 @@ export const actions = { async ActGetBaseUserDetails({ commit, state }, sharedBaseId) { try { try { - const user = await this.$api.auth.me({ // '/user/me', { + const user = await this.$api.auth.me({}, { headers: { 'xc-shared-base-id': sharedBaseId }