fixing users api references

This commit is contained in:
Peter Clement 2022-07-06 08:45:22 +01:00
parent 00ef0e3ef9
commit 6df456411f
15 changed files with 65 additions and 214 deletions

View File

@ -1,41 +0,0 @@
exports.SEPARATOR = "_"
const PRE_APP = "app"
const PRE_DEV = "dev"
exports.DocumentTypes = {
USER: "us",
WORKSPACE: "workspace",
CONFIG: "config",
TEMPLATE: "template",
APP: PRE_APP,
DEV: PRE_DEV,
APP_DEV: `${PRE_APP}${exports.SEPARATOR}${PRE_DEV}`,
APP_METADATA: `${PRE_APP}${exports.SEPARATOR}metadata`,
ROLE: "role",
MIGRATIONS: "migrations",
DEV_INFO: "devinfo",
GROUP: "gr",
}
exports.StaticDatabases = {
GLOBAL: {
name: "global-db",
docs: {
apiKeys: "apikeys",
usageQuota: "usage_quota",
licenseInfo: "license_info",
},
},
// contains information about tenancy and so on
PLATFORM_INFO: {
name: "global-info",
docs: {
tenants: "tenants",
},
},
}
exports.APP_PREFIX = exports.DocumentTypes.APP + exports.SEPARATOR
exports.APP_DEV = exports.APP_DEV_PREFIX =
exports.DocumentTypes.APP_DEV + exports.SEPARATOR

View File

@ -21,6 +21,7 @@ export enum ViewNames {
export enum DocumentTypes {
USER = "us",
GROUP = "gr",
WORKSPACE = "workspace",
CONFIG = "config",
TEMPLATE = "template",

View File

@ -150,7 +150,7 @@ exports.generateUserGroupID = () => {
/**
* Gets parameters for retrieving groups.
*/
exports.getUserGroupsParams = (groupId, otherProps = {}) => {
exports.getUserGroupsParams = (groupId: any, otherProps = {}) => {
if (!groupId) {
groupId = ""
}

View File

@ -291,11 +291,6 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/types@^1.0.206":
version "1.0.208"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.208.tgz#c45cb494fb5b85229e15a34c6ac1805bae5be867"
integrity sha512-zKIHg6TGK+soVxMNZNrGypP3DCrd3jhlUQEFeQ+rZR6/tCue1G74bjzydY5FjnLEsXeLH1a0hkS5HulTmvQ2bA==
"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"

View File

@ -127,7 +127,6 @@
} else {
try {
await organisation.init()
await roles.fetch()
} catch (error) {
notifications.error("Error getting org config")
}

View File

@ -22,19 +22,13 @@
<div class="modal-inner">
<Body size="XS">Icon</Body>
<div class="modal-spacing">
<IconPicker
on:change={e => (group.icon = e.detail)}
bind:value={group.icon}
/>
<IconPicker on:change={e => (group.icon = e.detail)} />
</div>
</div>
<div class="modal-inner">
<Body size="XS">Color</Body>
<div class="modal-spacing">
<ColorPicker
bind:value={group.color}
on:change={e => (group.color = e.detail)}
/>
<ColorPicker on:change={e => (group.color = e.detail)} />
</div>
</div>
</div>

View File

@ -18,8 +18,8 @@
let modal
let group = {
name: "",
icon: "",
color: "",
icon: "UserGroup",
color: "var(--spectrum-global-color-blue-600)",
users: [],
apps: [],
}
@ -34,6 +34,7 @@
}
async function saveGroup(group) {
console.log(group)
try {
await groups.actions.save(group)
} catch (error) {

View File

@ -20,13 +20,8 @@
export let showOnboardingTypeModal
const dispatch = createEventDispatcher()
const password = Math.random().toString(36).substring(2, 22)
const options = ["Email onboarding", "Basic onboarding"]
const [email, error, touched] = createValidationStore("", emailValidator)
let disabled
let builder
let admin
let selected = "Email onboarding"
$: userData = [{ email: "", role: "", groups: [], error: null }]
@ -38,46 +33,11 @@
function setValue(e) {
userData.groups = e.detail
}
$: basic = selected === "Basic onboarding"
function addUser() {
if (basic) {
createUser()
} else {
createUserFlow()
}
}
async function createUser() {
try {
await users.create({
email: $email,
password,
builder,
admin,
forceResetPassword: true,
})
notifications.success("Successfully created user")
dispatch("created")
} catch (error) {
notifications.error("Error creating user")
}
}
async function createUserFlow() {
try {
const res = await users.invite({ email: $email, builder, admin })
notifications.success(res.message)
} catch (error) {
notifications.error("Error inviting user")
}
}
</script>
<ModalContent
onConfirm={() => {
showOnboardingTypeModal()
addUser()
dispatch("change", userData)
}}
size="M"
@ -102,32 +62,7 @@
<div>
<ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton>
</div>
<div>
<Body size="S">
If you have SMTP configured and an email for the new user, you can use
the automated email onboarding flow. Otherwise, use our basic onboarding
process with autogenerated passwords.
</Body>
<Select
placeholder={null}
bind:value={selected}
{options}
label="Add new user via:"
/>
<Input
type="email"
label="Email"
bind:value={$email}
error={$touched && $error}
placeholder="john@doe.com"
/>
{#if basic}
<Input disabled label="Password" value={password} />
{/if}
</div></Layout
>
</Layout>
<Multiselect
placeholder="Select User Groups"

View File

@ -13,7 +13,6 @@
Pagination,
} from "@budibase/bbui"
import AddUserModal from "./_components/AddUserModal.svelte"
import BasicOnboardingModal from "./_components/BasicOnboardingModal.svelte"
import { users, groups } from "stores/portal"
import { onMount } from "svelte"
import GroupsTableRenderer from "./_components/GroupsTableRenderer.svelte"
@ -75,36 +74,7 @@
search = undefined
$: page = $pageInfo.page
$: fetchUsers(page, search)
$: filteredUsers = $users
.filter(user => user.email.includes(search || ""))
.map(user => ({
...user,
group: ["All users"],
developmentAccess: !!user.builder?.global,
adminAccess: !!user.admin?.global,
}))
$: enrichedUsers = $users.map(user => {
let userGroups = []
let userApps = []
$groups.forEach(group => {
if (group.users) {
group.users?.forEach(y => {
if (y._id === user._id) {
userGroups.push(group)
userApps = group.apps
}
})
}
})
return {
...user,
name: user.firstName ? user.firstName + " " + user.lastName : "",
userGroups,
apps: [...new Set(Object.keys(user.roles))],
}
})
$: console.log(page)
function showOnboardingTypeModal() {
onboardingTypeModal.show()
@ -206,22 +176,6 @@
>Import Users</Button
>
</ButtonGroup>
<Table
on:click={({ detail }) => $goto(`./${detail._id}`)}
{schema}
data={$users.data}
allowEditColumns={false}
allowEditRows={false}
allowSelectRows={true}
showHeaderBorder={false}
customRenderers={[
{ column: "userGroups", component: GroupsTableRenderer },
{ column: "apps", component: AppsTableRenderer },
{ column: "name", component: NameTableRenderer },
{ column: "settings", component: SettingsTableRenderer },
{ column: "role", component: RoleTableRenderer },
]}
/>
<div class="pagination">
<Pagination
page={$pageInfo.pageNumber}
@ -270,8 +224,6 @@
<ImportUsersModal {showOnboardingTypeModal} />
</Modal>
<Modal bind:this={basicOnboardingModal}><BasicOnboardingModal {email} /></Modal>
<style>
.access-description {
display: flex;

View File

@ -307,6 +307,7 @@
</Tab>
<Tab title="Access">
<AccessTab app={selectedApp} />
</Tab>
<Tab title="Automation History">
<HistoryTab app={selectedApp} />
</Tab>

View File

@ -69,18 +69,7 @@ export function createUsersStore() {
}
async function save(user) {
const response = await API.saveUser(user)
user._id = response._id
user._rev = response._rev
store.update(state => {
const currentIdx = state.findIndex(user => user._id === user._id)
if (currentIdx >= 0) {
state.splice(currentIdx, 1, user)
} else {
state.push(user)
}
return state
})
return await API.saveUser(user)
}
return {

View File

@ -28,6 +28,7 @@ const DocumentTypes = {
TABLE: "ta",
ROW: "ro",
USER: "us",
GROUP: "gr",
AUTOMATION: "au",
LINK: "li",
WEBHOOK: "wh",

View File

@ -1080,12 +1080,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.212-alpha.10":
version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.10.tgz#21c74d209c5fecea4b49e0c59db87069493169bc"
integrity sha512-8UcYfVC/8HYK3QkdysSVyiPUbNHXKpayoM9NMrJEA+QUSRcchQBLn1/5qhEAwfnPz55X+BlNV1whIJdMzXbP2A==
"@budibase/backend-core@1.0.212-alpha.15":
version "1.0.212-alpha.15"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.15.tgz#90ad9fed55a1e08c3ae69069e5d01e51477afd13"
integrity sha512-auIkpv9/W6iA1brt4vUtZivTS/8baqgPATOb+CCGzCukcDvrxkBQEEepAz0DYonKlFznsKSMkjOvgAY70wcm2Q==
dependencies:
"@budibase/types" "^1.0.212-alpha.10"
"@budibase/types" "^1.0.212-alpha.15"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -1101,6 +1101,7 @@
passport-google-oauth "2.0.0"
passport-jwt "4.0.0"
passport-local "1.0.0"
passport-oauth2-refresh "^2.1.0"
posthog-node "1.3.0"
pouchdb "7.3.0"
pouchdb-find "7.2.2"
@ -1161,12 +1162,13 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.0.212-alpha.10":
version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.10.tgz#0a0c2e695884075db03068c93705d1bc233b0c7a"
integrity sha512-qNzaT7+Wyy7roS/QX/WCpyhddapbarur3uPj8SBfVql8YEvEZw/f+3aOS3Ixj5m5r5eQxphWm/dCXC3RYjXKFg==
"@budibase/pro@1.0.212-alpha.15":
version "1.0.212-alpha.15"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.15.tgz#b1fe270960828ee5e096b7f958114c3782303deb"
integrity sha512-sAUeauSROZiTdQUB8PSjVrGi+C//sMvxs5B4kSBgu0+pJ5kDaa6jOd291dMfDFgVTlHQJvzGM0Z+FXooYIHLAQ==
dependencies:
"@budibase/backend-core" "1.0.212-alpha.10"
"@budibase/backend-core" "1.0.212-alpha.15"
"@budibase/types" "1.0.212-alpha.12"
node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139":
@ -1187,10 +1189,15 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@^1.0.212-alpha.10":
version "1.0.214"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.214.tgz#400724fb23a1ce4b80bd04ed472a376d59126069"
integrity sha512-KD9XkCdL+R4Nal/X2IX0Bv+AxsylGzAAmo7M6tuoM7YAegskmsX5Kfk5yasnbMnhOdICyvbJ1D6Hz7WKwdApzw==
"@budibase/types@1.0.212-alpha.12":
version "1.0.212-alpha.12"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.212-alpha.12.tgz#d45aa03d18f9ddc20d66e034072c0dc759eaf1ed"
integrity sha512-o4ZXUuqW6ryLj9/LptXBRwPPofl6PB5eo+HDt7KNMq7beVSC48uS+N/cQEF325OKrrulZRAGEStnUaLkFz3M9A==
"@budibase/types@^1.0.212-alpha.15":
version "1.0.218"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.218.tgz#534dd41c4a42a9061256c75b46bd78ec27ce47cd"
integrity sha512-X5mNdkHZtjEp/B+5mrtcTTUAj76XkF1U6/kEA9sQ9XHano9b22u/gbXTm/VdSuwqTXwN9abh5xAHhZDNSCrgiw==
"@bull-board/api@3.7.0":
version "3.7.0"
@ -10570,6 +10577,11 @@ passport-oauth1@1.x.x:
passport-strategy "1.x.x"
utils-merge "1.x.x"
passport-oauth2-refresh@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/passport-oauth2-refresh/-/passport-oauth2-refresh-2.1.0.tgz#c31cd133826383f5539d16ad8ab4f35ca73ce4a4"
integrity sha512-4ML7ooCESCqiTgdDBzNUFTBcPR8zQq9iM6eppEUGMMvLdsjqRL93jKwWm4Az3OJcI+Q2eIVyI8sVRcPFvxcF/A==
passport-oauth2@1.x.x:
version "1.6.1"
resolved "https://registry.yarnpkg.com/passport-oauth2/-/passport-oauth2-1.6.1.tgz#c5aee8f849ce8bd436c7f81d904a3cd1666f181b"

View File

@ -152,7 +152,7 @@ export const inviteMultiple = async (ctx: any) => {
let existing = false
let existingEmail
for (let email of emails) {
if (await getGlobalUserByEmail(email)) {
if (await usersCore.getGlobalUserByEmail(email)) {
existing = true
existingEmail = email
break

View File

@ -293,12 +293,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.212-alpha.10":
version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.10.tgz#21c74d209c5fecea4b49e0c59db87069493169bc"
integrity sha512-8UcYfVC/8HYK3QkdysSVyiPUbNHXKpayoM9NMrJEA+QUSRcchQBLn1/5qhEAwfnPz55X+BlNV1whIJdMzXbP2A==
"@budibase/backend-core@1.0.212-alpha.15":
version "1.0.212-alpha.15"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.212-alpha.15.tgz#90ad9fed55a1e08c3ae69069e5d01e51477afd13"
integrity sha512-auIkpv9/W6iA1brt4vUtZivTS/8baqgPATOb+CCGzCukcDvrxkBQEEepAz0DYonKlFznsKSMkjOvgAY70wcm2Q==
dependencies:
"@budibase/types" "^1.0.212-alpha.10"
"@budibase/types" "^1.0.212-alpha.15"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -314,6 +314,7 @@
passport-google-oauth "2.0.0"
passport-jwt "4.0.0"
passport-local "1.0.0"
passport-oauth2-refresh "^2.1.0"
posthog-node "1.3.0"
pouchdb "7.3.0"
pouchdb-find "7.2.2"
@ -325,18 +326,24 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.0.212-alpha.10":
version "1.0.212-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.10.tgz#0a0c2e695884075db03068c93705d1bc233b0c7a"
integrity sha512-qNzaT7+Wyy7roS/QX/WCpyhddapbarur3uPj8SBfVql8YEvEZw/f+3aOS3Ixj5m5r5eQxphWm/dCXC3RYjXKFg==
"@budibase/pro@1.0.212-alpha.15":
version "1.0.212-alpha.15"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.212-alpha.15.tgz#b1fe270960828ee5e096b7f958114c3782303deb"
integrity sha512-sAUeauSROZiTdQUB8PSjVrGi+C//sMvxs5B4kSBgu0+pJ5kDaa6jOd291dMfDFgVTlHQJvzGM0Z+FXooYIHLAQ==
dependencies:
"@budibase/backend-core" "1.0.212-alpha.10"
"@budibase/backend-core" "1.0.212-alpha.15"
"@budibase/types" "1.0.212-alpha.12"
node-fetch "^2.6.1"
"@budibase/types@^1.0.212-alpha.10":
version "1.0.214"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.214.tgz#400724fb23a1ce4b80bd04ed472a376d59126069"
integrity sha512-KD9XkCdL+R4Nal/X2IX0Bv+AxsylGzAAmo7M6tuoM7YAegskmsX5Kfk5yasnbMnhOdICyvbJ1D6Hz7WKwdApzw==
"@budibase/types@1.0.212-alpha.12":
version "1.0.212-alpha.12"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.212-alpha.12.tgz#d45aa03d18f9ddc20d66e034072c0dc759eaf1ed"
integrity sha512-o4ZXUuqW6ryLj9/LptXBRwPPofl6PB5eo+HDt7KNMq7beVSC48uS+N/cQEF325OKrrulZRAGEStnUaLkFz3M9A==
"@budibase/types@^1.0.212-alpha.15":
version "1.0.218"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.218.tgz#534dd41c4a42a9061256c75b46bd78ec27ce47cd"
integrity sha512-X5mNdkHZtjEp/B+5mrtcTTUAj76XkF1U6/kEA9sQ9XHano9b22u/gbXTm/VdSuwqTXwN9abh5xAHhZDNSCrgiw==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"
@ -4981,6 +4988,11 @@ passport-oauth1@1.x.x:
passport-strategy "1.x.x"
utils-merge "1.x.x"
passport-oauth2-refresh@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/passport-oauth2-refresh/-/passport-oauth2-refresh-2.1.0.tgz#c31cd133826383f5539d16ad8ab4f35ca73ce4a4"
integrity sha512-4ML7ooCESCqiTgdDBzNUFTBcPR8zQq9iM6eppEUGMMvLdsjqRL93jKwWm4Az3OJcI+Q2eIVyI8sVRcPFvxcF/A==
passport-oauth2@1.x.x:
version "1.6.1"
resolved "https://registry.yarnpkg.com/passport-oauth2/-/passport-oauth2-1.6.1.tgz#c5aee8f849ce8bd436c7f81d904a3cd1666f181b"