Quick updates based on latest lerna version, as well as some fixes after running through flows (post refactoring).

This commit is contained in:
mike12345567 2023-07-26 18:13:18 +01:00
parent c2793ede4c
commit eefac0fe08
8 changed files with 45 additions and 42 deletions

View File

@ -51,8 +51,8 @@
"kill-builder": "kill-port 3000",
"kill-server": "kill-port 4001 4002",
"kill-all": "yarn run kill-builder && yarn run kill-server",
"dev": "yarn run kill-all && yarn nx run-many --target=dev:builder",
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && yarn nx run-many --target=dev:builder --exclude=@budibase/backend-core,@budibase/server,@budibase/worker",
"dev": "yarn run kill-all && yarn nx run-many --target=dev:builder --parallel=10",
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && yarn nx run-many --target=dev:builder --parallel=10 --exclude=@budibase/backend-core,@budibase/server,@budibase/worker",
"dev:server": "yarn run kill-server && yarn nx run-many --target=dev:builder --projects=@budibase/worker,@budibase/server",
"dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream dev:built",
"dev:docker": "yarn build:docker:pre && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0",

View File

@ -15,6 +15,7 @@
import CreateAppModal from "components/start/CreateAppModal.svelte"
import AppLimitModal from "components/portal/licensing/AppLimitModal.svelte"
import AccountLockedModal from "components/portal/licensing/AccountLockedModal.svelte"
import { sdk } from "@budibase/shared-core"
import { store, automationStore } from "builderStore"
import { API } from "api"
@ -237,35 +238,37 @@
{#if enrichedApps.length}
<Layout noPadding gap="L">
<div class="title">
<div class="buttons">
<Button
size="M"
cta
on:click={usersLimitLockAction || initiateAppCreation}
>
Create new app
</Button>
{#if $apps?.length > 0 && !$admin.offlineMode}
{#if sdk.isGlobalBuilder($auth.user)}
<div class="buttons">
<Button
size="M"
secondary
on:click={usersLimitLockAction ||
$goto("/builder/portal/apps/templates")}
cta
on:click={usersLimitLockAction || initiateAppCreation}
>
View templates
Create new app
</Button>
{/if}
{#if !$apps?.length}
<Button
size="L"
quiet
secondary
on:click={usersLimitLockAction || initiateAppImport}
>
Import app
</Button>
{/if}
</div>
{#if $apps?.length > 0 && !$admin.offlineMode}
<Button
size="M"
secondary
on:click={usersLimitLockAction ||
$goto("/builder/portal/apps/templates")}
>
View templates
</Button>
{/if}
{#if !$apps?.length}
<Button
size="L"
quiet
secondary
on:click={usersLimitLockAction || initiateAppImport}
>
Import app
</Button>
{/if}
</div>
{/if}
{#if enrichedApps.length > 1}
<div class="app-actions">
<Select

View File

@ -55,7 +55,7 @@ async function passportCallback(
export const login = async (ctx: Ctx<LoginRequest>, next: any) => {
const email = ctx.request.body.username
const user = await userSdk.getUserByEmail(email)
const user = await userSdk.db.getUserByEmail(email)
if (user && (await userSdk.isPreventPasswordActions(user))) {
ctx.throw(403, "Invalid credentials")
}
@ -174,7 +174,7 @@ export const googlePreAuth = async (ctx: any, next: any) => {
const strategy = await google.strategyFactory(
config,
callbackUrl,
userSdk.save
userSdk.db.save
)
return passport.authenticate(strategy, {
@ -193,7 +193,7 @@ export const googleCallback = async (ctx: any, next: any) => {
const strategy = await google.strategyFactory(
config,
callbackUrl,
userSdk.save
userSdk.db.save
)
return passport.authenticate(
@ -228,7 +228,7 @@ export const oidcStrategyFactory = async (ctx: any, configId: any) => {
//Remote Config
const enrichedConfig = await oidc.fetchStrategyConfig(config, callbackUrl)
return oidc.strategyFactory(enrichedConfig, userSdk.save)
return oidc.strategyFactory(enrichedConfig, userSdk.db.save)
}
/**

View File

@ -91,7 +91,7 @@ export async function getSelf(ctx: any) {
}
// get the main body of the user
const user = await userSdk.getUser(userId)
const user = await userSdk.db.getUser(userId)
ctx.body = await groups.enrichUserRolesFromGroups(user)
// add the feature flags for this tenant
@ -106,12 +106,12 @@ export async function updateSelf(
) {
const update = ctx.request.body
let user = await userSdk.getUser(ctx.user._id!)
let user = await userSdk.db.getUser(ctx.user._id!)
user = {
...user,
...update,
}
user = await userSdk.save(user, { requirePassword: false })
user = await userSdk.db.save(user, { requirePassword: false })
if (update.password) {
// Log all other sessions out apart from the current one

View File

@ -41,7 +41,7 @@ describe("/api/global/auth", () => {
async function createSSOUser() {
return config.doInTenant(async () => {
return userSdk.save(structures.users.ssoUser(), {
return userSdk.db.save(structures.users.ssoUser(), {
requirePassword: false,
})
})
@ -206,7 +206,7 @@ describe("/api/global/auth", () => {
const newPassword = "newpassword"
const res = await config.api.auth.updatePassword(code!, newPassword)
user = await config.getUser(user.email)
user = await config.getUser(user.email) as User
delete user.password
expect(res.body).toEqual({ message: "password reset successfully." })
@ -245,7 +245,7 @@ describe("/api/global/auth", () => {
const ssoUser = user as SSOUser
ssoUser.providerType = structures.sso.providerType()
delete ssoUser.password
await config.doInTenant(() => userSdk.save(ssoUser))
await config.doInTenant(() => userSdk.db.save(ssoUser))
await testSSOUser(code!)
})

View File

@ -480,7 +480,7 @@ describe("/api/global/users", () => {
function createSSOUser() {
return config.doInTenant(() => {
const user = structures.users.ssoUser()
return userSdk.save(user, { requirePassword: false })
return userSdk.db.save(user, { requirePassword: false })
})
}

View File

@ -5,8 +5,8 @@ export const initPro = async () => {
await proSdk.init({
scimUserServiceConfig: {
functions: {
saveUser: userSdk.save,
removeUser: (id: string) => userSdk.destroy(id),
saveUser: userSdk.db.save,
removeUser: (id: string) => userSdk.db.destroy(id),
},
},
})

View File

@ -76,9 +76,9 @@ export const reset = async (email: string) => {
export const resetUpdate = async (resetCode: string, password: string) => {
const { userId } = await redis.checkResetPasswordCode(resetCode)
let user = await userSdk.getUser(userId)
let user = await userSdk.db.getUser(userId)
user.password = password
user = await userSdk.save(user)
user = await userSdk.db.save(user)
// remove password from the user before sending events
delete user.password