mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-10 11:47:42 +02:00
Use consistent error codes for authorization errors from transaction (#10040)
Signed-off-by: Nikolay Marchuk <nikolay.marchuk@hardcoreeng.com>
This commit is contained in:
@@ -163,7 +163,7 @@ export function registerRPC (app: Express, sessions: SessionManager, ctx: Measur
|
||||
|
||||
const decodedToken = decodeToken(token)
|
||||
if (workspaceId !== decodedToken.workspace) {
|
||||
sendError(res, 401, { message: 'Invalid workspace', workspace: decodedToken.workspace })
|
||||
sendError(res, 403, { message: 'Invalid workspace', workspace: decodedToken.workspace })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ export function registerRPC (app: Express, sessions: SessionManager, ctx: Measur
|
||||
const cs: ConnectionSocket = createClosingSocket(token, rpcSessions)
|
||||
const s = await sessions.addSession(ctx, cs, decodedToken, token, token)
|
||||
if (!('session' in s)) {
|
||||
sendError(res, 401, {
|
||||
sendError(res, 403, {
|
||||
message: 'Failed to create session',
|
||||
mode: 'specialError' in s ? s.specialError ?? '' : 'upgrading'
|
||||
})
|
||||
|
||||
@@ -321,7 +321,7 @@ export function startHttpServer (
|
||||
try {
|
||||
const authHeader = req.headers.authorization
|
||||
if (authHeader === undefined) {
|
||||
res.status(403).end(JSON.stringify({ error: 'Unauthorized' }))
|
||||
res.status(401).end(JSON.stringify({ error: 'Unauthorized' }))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ export function startHttpServer (
|
||||
const wsIds = await getWorkspaceIds(token)
|
||||
|
||||
if (wsIds.uuid == null) {
|
||||
res.status(401).end(JSON.stringify({ error: 'No workspace found' }))
|
||||
res.status(403).end(JSON.stringify({ error: 'No workspace found' }))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ export function startHttpServer (
|
||||
try {
|
||||
const authHeader = req.headers.authorization
|
||||
if (authHeader === undefined) {
|
||||
res.status(403).send({ error: 'Unauthorized' })
|
||||
res.status(401).send({ error: 'Unauthorized' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ export function startHttpServer (
|
||||
const wsIds = await getWorkspaceIds(token)
|
||||
|
||||
if (wsIds.uuid == null) {
|
||||
res.status(401).send({ error: 'No workspace found' })
|
||||
res.status(403).send({ error: 'No workspace found' })
|
||||
}
|
||||
|
||||
const name = req.query.name as string
|
||||
|
||||
Reference in New Issue
Block a user