build fixes.
This commit is contained in:
parent
0b7057dd1d
commit
35b097fa28
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,7 @@
|
|||
},
|
||||
"jest": {},
|
||||
"devDependencies": {
|
||||
"@types/json5": "^2.2.0",
|
||||
"@types/koa": "2.13.4",
|
||||
"@types/node": "14.18.20",
|
||||
"@types/pouchdb": "6.4.0",
|
||||
|
|
|
@ -25,6 +25,7 @@ export interface ThirdPartyUser extends Document {
|
|||
email: string
|
||||
userId?: string
|
||||
forceResetPassword?: boolean
|
||||
userGroups?: string[]
|
||||
}
|
||||
|
||||
export interface User extends ThirdPartyUser {
|
||||
|
@ -42,7 +43,6 @@ export interface User extends ThirdPartyUser {
|
|||
password?: string
|
||||
status?: string
|
||||
createdAt?: number // override the default createdAt behaviour - users sdk historically set this to Date.now()
|
||||
userGroups?: string[]
|
||||
dayPassRecordedAt?: string
|
||||
account?: {
|
||||
authType: string
|
||||
|
|
|
@ -75,6 +75,13 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-1.8.2.tgz#7315b4c4c54f82d13fa61c228ec5c2ea5cc9e0e1"
|
||||
integrity sha512-EqX+YQxINb+MeXaIqYDASb6U6FCHbWjkj4a1CKDBks3d/QiB2+PqBLyO72vLDgAO1wUI4O+9gweRcQK11bTL/w==
|
||||
|
||||
"@types/json5@^2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-2.2.0.tgz#afff29abf9182a7d4a7e39105ca051f11c603d13"
|
||||
integrity sha512-NrVug5woqbvNZ0WX+Gv4R+L4TGddtmFek2u8RtccAgFZWtS9QXF2xCXY22/M4nzkaKF0q9Fc6M/5rxLDhfwc/A==
|
||||
dependencies:
|
||||
json5 "*"
|
||||
|
||||
"@types/keygrip@*":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.2.tgz#513abfd256d7ad0bf1ee1873606317b33b1b2a72"
|
||||
|
@ -447,6 +454,11 @@ inherits@2:
|
|||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
|
||||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
||||
|
||||
json5@*:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
|
||||
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
|
||||
|
||||
mime-db@1.52.0:
|
||||
version "1.52.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
|
||||
|
|
|
@ -29,6 +29,7 @@ import {
|
|||
RowResponse,
|
||||
SearchUsersRequest,
|
||||
User,
|
||||
ThirdPartyUser,
|
||||
} from "@budibase/types"
|
||||
import { sendEmail } from "../../utilities/email"
|
||||
import { EmailTemplatePurpose } from "../../constants"
|
||||
|
@ -110,7 +111,7 @@ export interface SaveUserOpts {
|
|||
}
|
||||
|
||||
const buildUser = async (
|
||||
user: User,
|
||||
user: User | ThirdPartyUser,
|
||||
opts: SaveUserOpts = {
|
||||
hashPassword: true,
|
||||
requirePassword: true,
|
||||
|
@ -118,7 +119,8 @@ const buildUser = async (
|
|||
tenantId: string,
|
||||
dbUser?: any
|
||||
): Promise<User> => {
|
||||
let { password, _id } = user
|
||||
let fullUser = user as User
|
||||
let { password, _id } = fullUser
|
||||
|
||||
let hashedPassword
|
||||
if (password) {
|
||||
|
@ -131,24 +133,24 @@ const buildUser = async (
|
|||
|
||||
_id = _id || dbUtils.generateGlobalUserID()
|
||||
|
||||
user = {
|
||||
fullUser = {
|
||||
createdAt: Date.now(),
|
||||
...dbUser,
|
||||
...user,
|
||||
...fullUser,
|
||||
_id,
|
||||
password: hashedPassword,
|
||||
tenantId,
|
||||
}
|
||||
// make sure the roles object is always present
|
||||
if (!user.roles) {
|
||||
user.roles = {}
|
||||
if (!fullUser.roles) {
|
||||
fullUser.roles = {}
|
||||
}
|
||||
// add the active status to a user if its not provided
|
||||
if (user.status == null) {
|
||||
user.status = constants.UserStatus.ACTIVE
|
||||
if (fullUser.status == null) {
|
||||
fullUser.status = constants.UserStatus.ACTIVE
|
||||
}
|
||||
|
||||
return user
|
||||
return fullUser
|
||||
}
|
||||
|
||||
const validateUniqueUser = async (email: string, tenantId: string) => {
|
||||
|
@ -170,7 +172,7 @@ const validateUniqueUser = async (email: string, tenantId: string) => {
|
|||
}
|
||||
|
||||
export const save = async (
|
||||
user: User,
|
||||
user: User | ThirdPartyUser,
|
||||
opts: SaveUserOpts = {}
|
||||
): Promise<CreateUserResponse> => {
|
||||
// default booleans to true
|
||||
|
|
Loading…
Reference in New Issue