mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 17:05:16 +03:00
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
2a98f3c176
commit
b2f5c6708b
@ -12004,7 +12004,7 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:projects/pod-account.tgz:
|
file:projects/pod-account.tgz:
|
||||||
resolution: {integrity: sha512-1KP9YR2TMC9Zksf2G15aecCY4pIDpGaddPQ2BGtfkE2P/4XG6gYl2Mnf8GRr1c3r2IWJozLYw39MhpkXI9zCHQ==, tarball: file:projects/pod-account.tgz}
|
resolution: {integrity: sha512-LqJ4mBkjSWhBA9OiiMUgLeoUF9IniLh1xr/G3iXRHSm8Li6OssMSTZ733CAoWVNPchAMn5xBibLV5Mi6syer9w==, tarball: file:projects/pod-account.tgz}
|
||||||
name: '@rush-temp/pod-account'
|
name: '@rush-temp/pod-account'
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -12029,8 +12029,11 @@ packages:
|
|||||||
koa-router: 10.1.1
|
koa-router: 10.1.1
|
||||||
mongodb: 4.2.2
|
mongodb: 4.2.2
|
||||||
prettier: 2.5.1
|
prettier: 2.5.1
|
||||||
|
ts-node: 10.4.0_5d12c2add188ff0e728b4ade3dacd39b
|
||||||
typescript: 4.5.4
|
typescript: 4.5.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@swc/core'
|
||||||
|
- '@swc/wasm'
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
"status": {
|
"status": {
|
||||||
"LoadingPlugin": "Loading plugin '<b>'{plugin}'</b>'...",
|
"LoadingPlugin": "Loading plugin '<b>'{plugin}'</b>'...",
|
||||||
"UnknownError": "Unknown error: {message}",
|
"UnknownError": "Unknown error: {message}",
|
||||||
"InvalidId": "Invalid Id: {id}"
|
"InvalidId": "Invalid Id: {id}",
|
||||||
|
"BadRequest": "Bad request",
|
||||||
|
"Forbidden": "Forbidden",
|
||||||
|
"Unauthorized": "Unauthorized",
|
||||||
|
"UnknownMethod": "Unknown method: {method}",
|
||||||
|
"InternalServerError": "Internal server error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,7 @@ export default plugin(platformId, {
|
|||||||
BadRequest: '' as StatusCode,
|
BadRequest: '' as StatusCode,
|
||||||
Forbidden: '' as StatusCode,
|
Forbidden: '' as StatusCode,
|
||||||
Unauthorized: '' as StatusCode,
|
Unauthorized: '' as StatusCode,
|
||||||
UnknownMethod: '' as StatusCode<{ method: string }>
|
UnknownMethod: '' as StatusCode<{ method: string }>,
|
||||||
|
InternalServerError: '' as StatusCode
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { getMetadata, Metadata, Plugin, Request, Response, StatusCode, PlatformError, plugin, Severity, Status, unknownStatus } from '@anticrm/platform'
|
import platform, { getMetadata, Metadata, Plugin, Request, Response, PlatformError, plugin, Severity, Status, StatusCode } from '@anticrm/platform'
|
||||||
import { pbkdf2Sync, randomBytes } from 'crypto'
|
import { pbkdf2Sync, randomBytes } from 'crypto'
|
||||||
import { encode } from 'jwt-simple'
|
import { encode } from 'jwt-simple'
|
||||||
import { Binary, Db, ObjectId } from 'mongodb'
|
import { Binary, Db, ObjectId } from 'mongodb'
|
||||||
@ -45,8 +45,7 @@ const accountPlugin = plugin(accountId, {
|
|||||||
WorkspaceNotFound: '' as StatusCode<{workspace: string}>,
|
WorkspaceNotFound: '' as StatusCode<{workspace: string}>,
|
||||||
InvalidPassword: '' as StatusCode<{account: string}>,
|
InvalidPassword: '' as StatusCode<{account: string}>,
|
||||||
AccountAlreadyExists: '' as StatusCode<{account: string}>,
|
AccountAlreadyExists: '' as StatusCode<{account: string}>,
|
||||||
WorkspaceAlreadyExists: '' as StatusCode<{workspace: string}>,
|
WorkspaceAlreadyExists: '' as StatusCode<{workspace: string}>
|
||||||
Forbidden: '' as StatusCode
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -170,7 +169,7 @@ export async function login (db: Db, email: string, password: string, workspace:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PlatformError(new Status(Severity.ERROR, accountPlugin.status.Forbidden, {}))
|
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -304,7 +303,7 @@ function wrap (f: (db: Db, ...args: any[]) => Promise<any>) {
|
|||||||
return async function (db: Db, request: Request<any[]>): Promise<Response<any>> {
|
return async function (db: Db, request: Request<any[]>): Promise<Response<any>> {
|
||||||
return await f(db, ...request.params)
|
return await f(db, ...request.params)
|
||||||
.then((result) => ({ id: request.id, result }))
|
.then((result) => ({ id: request.id, result }))
|
||||||
.catch((err) => ({ error: unknownStatus(err) }))
|
.catch((err) => ({ error: err instanceof PlatformError ? new Status(Severity.ERROR, platform.status.Forbidden, {}) : new Status(Severity.ERROR, platform.status.InternalServerError, {}) }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user