Refactor
This commit is contained in:
parent
10fe86e30d
commit
a620bca62b
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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!,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue