Merge branch 'main' into iain/dockerfile-node18-node22
This commit is contained in:
@@ -18,8 +18,7 @@ import {
|
||||
getUserByEmail,
|
||||
findOrCreateUser,
|
||||
validatePasssword,
|
||||
createUser,
|
||||
getUserById
|
||||
createUser
|
||||
} from '@/modules/core/services/users'
|
||||
import {
|
||||
validateServerInviteFactory,
|
||||
@@ -40,6 +39,7 @@ import localStrategyBuilderFactory from '@/modules/auth/strategies/local'
|
||||
import oidcStrategyBuilderFactory from '@/modules/auth/strategies/oidc'
|
||||
import { getRateLimitResult } from '@/modules/core/services/ratelimiter'
|
||||
import { passportAuthenticateHandlerBuilderFactory } from '@/modules/auth/services/passportService'
|
||||
import { legacyGetUserFactory } from '@/modules/core/repositories/users'
|
||||
|
||||
const initializeDefaultApps = initializeDefaultAppsFactory({
|
||||
getAllScopes: getAllScopesFactory({ db }),
|
||||
@@ -64,7 +64,6 @@ const commonBuilderDeps = {
|
||||
validateServerInvite,
|
||||
finalizeInvitedServerRegistration,
|
||||
resolveAuthRedirectPath,
|
||||
getUserById,
|
||||
passportAuthenticateHandlerBuilder: passportAuthenticateHandlerBuilderFactory()
|
||||
}
|
||||
const setupStrategies = setupStrategiesFactory({
|
||||
@@ -81,7 +80,7 @@ const setupStrategies = setupStrategiesFactory({
|
||||
}),
|
||||
oidcStrategyBuilder: oidcStrategyBuilderFactory({ ...commonBuilderDeps }),
|
||||
createAuthorizationCode: createAuthorizationCodeFactory({ db }),
|
||||
getUserById
|
||||
getUser: legacyGetUserFactory({ db })
|
||||
})
|
||||
|
||||
let authStrategies: AuthStrategyMetadata[]
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
import { getSessionSecret } from '@/modules/shared/helpers/envHelper'
|
||||
import { isString, noop } from 'lodash'
|
||||
import { CreateAuthorizationCode } from '@/modules/auth/domain/operations'
|
||||
import { getUserById } from '@/modules/core/services/users'
|
||||
import { mixpanel } from '@/modules/shared/utils/mixpanel'
|
||||
import {
|
||||
addToMailchimpAudience,
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
} from '@/modules/auth/services/mailchimp'
|
||||
import { authLogger, logger } from '@/logging/logging'
|
||||
import { ensureError } from '@speckle/shared'
|
||||
import { LegacyGetUser } from '@/modules/core/domain/users/operations'
|
||||
|
||||
export const sessionMiddlewareFactory = (): RequestHandler => {
|
||||
const RedisStore = ConnectRedis(ExpressSession)
|
||||
@@ -72,7 +72,7 @@ export const moveAuthParamsToSessionMiddlewareFactory =
|
||||
export const finalizeAuthMiddlewareFactory =
|
||||
(deps: {
|
||||
createAuthorizationCode: CreateAuthorizationCode
|
||||
getUserById: typeof getUserById
|
||||
getUser: LegacyGetUser
|
||||
}): RequestHandler =>
|
||||
async (req, res) => {
|
||||
try {
|
||||
@@ -109,7 +109,7 @@ export const finalizeAuthMiddlewareFactory =
|
||||
|
||||
if (getMailchimpStatus()) {
|
||||
try {
|
||||
const user = await deps.getUserById({ userId: req.user.id })
|
||||
const user = await deps.getUser(req.user.id)
|
||||
if (!user)
|
||||
throw new Error(
|
||||
'Could not register user for mailchimp lists - no db user record found.'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import passport from 'passport'
|
||||
import { getUserById } from '@/modules/core/services/users'
|
||||
import type { Express } from 'express'
|
||||
import {
|
||||
AuthStrategyBuilder,
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
moveAuthParamsToSessionMiddlewareFactory,
|
||||
sessionMiddlewareFactory
|
||||
} from '@/modules/auth/middleware'
|
||||
import { LegacyGetUser } from '@/modules/core/domain/users/operations'
|
||||
|
||||
const setupStrategiesFactory =
|
||||
(deps: {
|
||||
@@ -21,7 +21,7 @@ const setupStrategiesFactory =
|
||||
localStrategyBuilder: AuthStrategyBuilder
|
||||
oidcStrategyBuilder: AuthStrategyBuilder
|
||||
createAuthorizationCode: CreateAuthorizationCode
|
||||
getUserById: typeof getUserById
|
||||
getUser: LegacyGetUser
|
||||
}) =>
|
||||
async (app: Express) => {
|
||||
passport.serializeUser((user, done) => done(null, user))
|
||||
|
||||
@@ -31,7 +31,6 @@ import {
|
||||
import { setupRunFinishedTrackingFactory } from '@/modules/automate/services/tracking'
|
||||
import authGithubAppRest from '@/modules/automate/rest/authGithubApp'
|
||||
import { getFeatureFlags } from '@/modules/shared/helpers/envHelper'
|
||||
import { getUserById } from '@/modules/core/services/users'
|
||||
import { TokenScopeData } from '@/modules/shared/domain/rolesAndScopes/types'
|
||||
import db from '@/db/knex'
|
||||
import { AutomationsEmitter } from '@/modules/automate/events/automations'
|
||||
@@ -40,6 +39,7 @@ import { AutomateRunsEmitter } from '@/modules/automate/events/runs'
|
||||
import { createAppToken } from '@/modules/core/services/tokens'
|
||||
import { getBranchLatestCommitsFactory } from '@/modules/core/repositories/branches'
|
||||
import { getCommitFactory } from '@/modules/core/repositories/commits'
|
||||
import { legacyGetUserFactory } from '@/modules/core/repositories/users'
|
||||
|
||||
const { FF_AUTOMATE_MODULE_ENABLED } = getFeatureFlags()
|
||||
let quitListeners: Optional<() => void> = undefined
|
||||
@@ -101,7 +101,7 @@ const initializeEventListeners = () => {
|
||||
})
|
||||
const setupRunFinishedTrackingInvoke = setupRunFinishedTrackingFactory({
|
||||
getFullAutomationRevisionMetadata,
|
||||
getUserById,
|
||||
getUser: legacyGetUserFactory({ db }),
|
||||
getCommit: getCommitFactory({ db }),
|
||||
getFullAutomationRunById: getFullAutomationRunByIdFactory({ db }),
|
||||
automateRunsEventListener: AutomateRunsEmitter.listen
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from '@/modules/automate/helpers/types'
|
||||
import { InsertableAutomationRun } from '@/modules/automate/repositories/automations'
|
||||
import { GetCommit } from '@/modules/core/domain/commits/operations'
|
||||
import { getUserById } from '@/modules/core/services/users'
|
||||
import { LegacyGetUser } from '@/modules/core/domain/users/operations'
|
||||
import { mixpanel } from '@/modules/shared/utils/mixpanel'
|
||||
import { throwUncoveredError } from '@speckle/shared'
|
||||
|
||||
@@ -37,7 +37,7 @@ export type AutomateTrackingDeps = {
|
||||
getFullAutomationRevisionMetadata: GetFullAutomationRevisionMetadata
|
||||
getFullAutomationRunById: GetFullAutomationRunById
|
||||
getCommit: GetCommit
|
||||
getUserById: typeof getUserById
|
||||
getUser: LegacyGetUser
|
||||
}
|
||||
|
||||
const onAutomationRunStatusUpdatedFactory =
|
||||
@@ -103,7 +103,7 @@ const getUserEmailFromAutomationRunFactory =
|
||||
if (!version) throw new Error("Version doesn't exist any more")
|
||||
const userId = version.author
|
||||
if (userId) {
|
||||
const user = await deps.getUserById({ userId })
|
||||
const user = await deps.getUser(userId)
|
||||
if (user) userEmail = user.email
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ const {
|
||||
getPaginatedStreamBranches
|
||||
} = require('@/modules/core/services/branch/retrieval')
|
||||
|
||||
const { getUserById } = require('../../services/users')
|
||||
const { Roles } = require('@speckle/shared')
|
||||
const {
|
||||
getBranchByIdFactory,
|
||||
@@ -37,6 +36,7 @@ const {
|
||||
markBranchStreamUpdatedFactory
|
||||
} = require('@/modules/core/repositories/streams')
|
||||
const { ModelsEmitter } = require('@/modules/core/events/modelsEmitter')
|
||||
const { legacyGetUserFactory } = require('@/modules/core/repositories/users')
|
||||
|
||||
// subscription events
|
||||
const BRANCH_CREATED = BranchPubsubEvents.BranchCreated
|
||||
@@ -65,6 +65,7 @@ const deleteBranchAndNotify = deleteBranchAndNotifyFactory({
|
||||
addBranchDeletedActivity,
|
||||
deleteBranchById: deleteBranchByIdFactory({ db })
|
||||
})
|
||||
const getUser = legacyGetUserFactory({ db })
|
||||
|
||||
/** @type {import('@/modules/core/graph/generated/graphql').Resolvers} */
|
||||
module.exports = {
|
||||
@@ -94,8 +95,7 @@ module.exports = {
|
||||
},
|
||||
Branch: {
|
||||
async author(parent, args, context) {
|
||||
if (parent.authorId && context.auth)
|
||||
return await getUserById({ userId: parent.authorId })
|
||||
if (parent.authorId && context.auth) return await getUser(parent.authorId)
|
||||
else return null
|
||||
}
|
||||
},
|
||||
|
||||
@@ -17,11 +17,7 @@ const Users = () => UsersSchema.knex()
|
||||
const Acl = () => ServerAclSchema.knex()
|
||||
|
||||
const { LIMITED_USER_FIELDS } = require('@/modules/core/helpers/userHelper')
|
||||
const {
|
||||
getUserByEmail,
|
||||
getUserFactory,
|
||||
legacyGetUserFactory
|
||||
} = require('@/modules/core/repositories/users')
|
||||
const { getUserByEmail, getUserFactory } = require('@/modules/core/repositories/users')
|
||||
const { UsersEmitter, UsersEvents } = require('@/modules/core/events/usersEmitter')
|
||||
const { pick, omit } = require('lodash')
|
||||
const { dbLogger } = require('@/logging/logging')
|
||||
@@ -194,14 +190,6 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated Use getUser instead
|
||||
*/
|
||||
async getUserById({ userId }) {
|
||||
const getUser = legacyGetUserFactory({ db })
|
||||
return await getUser(userId)
|
||||
},
|
||||
|
||||
// TODO: this should be moved to repository
|
||||
async getUserByEmail({ email }) {
|
||||
const user = await Users()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect } from 'chai'
|
||||
import { createUser, getUserById } from '@/modules/core/services/users'
|
||||
import { createUser } from '@/modules/core/services/users'
|
||||
import { beforeEach, describe, it } from 'mocha'
|
||||
import { beforeEachContext } from '@/test/hooks'
|
||||
import { db } from '@/db/knex'
|
||||
@@ -77,7 +77,7 @@ describe('Users @core-users', () => {
|
||||
password: createRandomPassword()
|
||||
})
|
||||
|
||||
const user = await getUserById({ userId })
|
||||
const user = await getUser(userId)
|
||||
expect(user).to.be.ok
|
||||
expect(user!.email.toLowerCase()).to.eq(email.toLowerCase())
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ const {
|
||||
updateUser,
|
||||
deleteUser,
|
||||
validatePasssword,
|
||||
updateUserPassword,
|
||||
getUserById
|
||||
updateUserPassword
|
||||
} = require('../services/users')
|
||||
const {
|
||||
createPersonalAccessToken,
|
||||
@@ -194,7 +193,7 @@ describe('Actors & Tokens @user-services', () => {
|
||||
const { id } = await findOrCreateUser({ user: newUser })
|
||||
ballmerUserId = id
|
||||
expect(id).to.be.a('string')
|
||||
const user = await getUserById({ userId: id })
|
||||
const user = await getUser(id)
|
||||
expect(user.verified).to.equal(true)
|
||||
})
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ import {
|
||||
sessionMiddlewareFactory
|
||||
} from '@/modules/auth/middleware'
|
||||
import { createAuthorizationCodeFactory } from '@/modules/auth/repositories/apps'
|
||||
import { getUserById } from '@/modules/core/services/users'
|
||||
import { legacyGetUserFactory } from '@/modules/core/repositories/users'
|
||||
|
||||
const router = Router()
|
||||
|
||||
const sessionMiddleware = sessionMiddlewareFactory()
|
||||
const finalizeAuthMiddleware = finalizeAuthMiddlewareFactory({
|
||||
createAuthorizationCode: createAuthorizationCodeFactory({ db }),
|
||||
getUserById
|
||||
getUser: legacyGetUserFactory({ db })
|
||||
})
|
||||
|
||||
const buildAuthRedirectUrl = (workspaceSlug: string): URL =>
|
||||
|
||||
Reference in New Issue
Block a user