Clean code
This commit is contained in:
parent
04bd9dda9c
commit
099cc145bf
5 changed files with 2 additions and 19 deletions
|
@ -19,12 +19,7 @@ export function doInIdentityContext(identity: IdentityContext, task: any) {
|
|||
}
|
||||
|
||||
// used in server/worker
|
||||
export function doInUserContext(
|
||||
user: User,
|
||||
ctx: Ctx,
|
||||
task: any,
|
||||
isScim: boolean
|
||||
) {
|
||||
export function doInUserContext(user: User, ctx: Ctx, task: any) {
|
||||
const userContext: UserContext = {
|
||||
...user,
|
||||
_id: user._id as string,
|
||||
|
@ -34,7 +29,6 @@ export function doInUserContext(
|
|||
// filled in by koa-useragent package
|
||||
userAgent: ctx.userAgent._agent.source,
|
||||
},
|
||||
isScimCall: isScim,
|
||||
}
|
||||
return doInIdentityContext(userContext, task)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
clearCookie,
|
||||
openJwt,
|
||||
isValidInternalAPIKey,
|
||||
isScimEndpoint,
|
||||
} from "../utils"
|
||||
import { getUser } from "../cache/user"
|
||||
import { getSession, updateSessionTTL } from "../security/sessions"
|
||||
|
@ -106,8 +105,6 @@ export default function (
|
|||
apiKey = ctx.request.headers[Header.AUTHORIZATION].split(" ")[1]
|
||||
}
|
||||
|
||||
const isScimCall = isScimEndpoint(ctx)
|
||||
|
||||
const tenantId = ctx.request.headers[Header.TENANT_ID]
|
||||
let authenticated = false,
|
||||
user = null,
|
||||
|
@ -171,7 +168,7 @@ export default function (
|
|||
finalise(ctx, { authenticated, user, internal, version, publicEndpoint })
|
||||
|
||||
if (user && user.email) {
|
||||
return identity.doInUserContext(user, ctx, next, isScimCall)
|
||||
return identity.doInUserContext(user, ctx, next)
|
||||
} else {
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import { Ctx } from "@budibase/types"
|
||||
|
||||
const SCIM_ENDPOINTS = new RegExp(["scim/"].join("|"))
|
||||
export function isScimEndpoint(ctx: Ctx): boolean {
|
||||
return SCIM_ENDPOINTS.test(ctx.request.url)
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
export * from "./hashing"
|
||||
export * from "./utils"
|
||||
export * from "./endpointUtils"
|
||||
|
|
|
@ -17,7 +17,6 @@ export interface UserContext extends BaseContext, User {
|
|||
tenantId: string
|
||||
account?: Account
|
||||
hostInfo: HostInfo
|
||||
isScimCall?: boolean
|
||||
}
|
||||
|
||||
export type IdentityContext = BaseContext | AccountUserContext | UserContext
|
||||
|
|
Loading…
Reference in a new issue