This commit is contained in:
Adria Navarro 2023-09-18 13:10:27 +02:00
parent d0097273b9
commit 6d6b3dd971
3 changed files with 27 additions and 25 deletions

View File

@ -1,19 +0,0 @@
import { User } from "@budibase/types"
import { generator } from "./generator"
import { uuid } from "./common"
export const newEmail = () => {
return `${uuid()}@test.com`
}
export const user = (userProps?: any): User => {
return {
email: newEmail(),
password: "test",
roles: { app_test: "admin" },
firstName: generator.first(),
lastName: generator.last(),
pictureUrl: "http://test.com",
...userProps,
}
}

View File

@ -13,8 +13,7 @@ import {
} from "@budibase/types"
import { generator } from "./generator"
import { email, uuid } from "./common"
import * as shared from "./shared"
import { user } from "./shared"
import * as users from "./users"
import sample from "lodash/sample"
export function OAuth(): OAuth2 {
@ -26,7 +25,7 @@ export function OAuth(): OAuth2 {
export function authDetails(userDoc?: User): SSOAuthDetails {
if (!userDoc) {
userDoc = user()
userDoc = users.user()
}
const userId = userDoc._id || uuid()
@ -52,7 +51,7 @@ export function providerType(): SSOProviderType {
export function ssoProfile(user?: User): SSOProfile {
if (!user) {
user = shared.user()
user = users.user()
}
return {
id: user._id!,

View File

@ -4,11 +4,33 @@ import {
BuilderUser,
SSOAuthDetails,
SSOUser,
User,
} from "@budibase/types"
import { user } from "./shared"
import { authDetails } from "./sso"
import { uuid } from "./common"
import { generator } from "./generator"
import { tenant } from "."
import { generateGlobalUserID } from "../../../../src/docIds"
export { user, newEmail } from "./shared"
export const newEmail = () => {
return `${uuid()}@test.com`
}
export const user = (userProps?: Partial<Omit<User, "userId">>): User => {
const userId = userProps?._id || generateGlobalUserID()
return {
_id: userId,
userId,
email: newEmail(),
password: "test",
roles: { app_test: "admin" },
firstName: generator.first(),
lastName: generator.last(),
pictureUrl: "http://test.com",
tenantId: tenant.id(),
...userProps,
}
}
export const adminUser = (userProps?: any): AdminUser => {
return {