Make generated passwords longer (#14362)
* Make generated passwords longer * Use crypto for generating passwords * Remove comments * Generate password with length 12
This commit is contained in:
parent
d0f1dc2937
commit
151fff51c5
|
@ -16,7 +16,7 @@
|
|||
|
||||
export let showOnboardingTypeModal
|
||||
|
||||
const password = Math.random().toString(36).substring(2, 22)
|
||||
const password = generatePassword(12)
|
||||
let disabled
|
||||
let userGroups = []
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
|||
{
|
||||
email: "",
|
||||
role: "appUser",
|
||||
password: Math.random().toString(36).substring(2, 22),
|
||||
password: generatePassword(12),
|
||||
forceResetPassword: true,
|
||||
error: null,
|
||||
},
|
||||
|
@ -69,6 +69,14 @@
|
|||
return userData[index].error == null
|
||||
}
|
||||
|
||||
function generatePassword(length) {
|
||||
const array = new Uint8Array(length)
|
||||
window.crypto.getRandomValues(array)
|
||||
return Array.from(array, byte => byte.toString(36).padStart(2, "0"))
|
||||
.join("")
|
||||
.slice(0, length)
|
||||
}
|
||||
|
||||
const onConfirm = () => {
|
||||
let valid = true
|
||||
userData.forEach((input, index) => {
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
const newUser = {
|
||||
email: email,
|
||||
role: usersRole,
|
||||
password: Math.random().toString(36).substring(2, 22),
|
||||
password: generatePassword(12),
|
||||
forceResetPassword: true,
|
||||
}
|
||||
|
||||
|
@ -288,6 +288,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
const generatePassword = length => {
|
||||
const array = new Uint8Array(length)
|
||||
window.crypto.getRandomValues(array)
|
||||
return Array.from(array, byte => byte.toString(36).padStart(2, "0"))
|
||||
.join("")
|
||||
.slice(0, length)
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
await groups.actions.init()
|
||||
|
|
|
@ -41,6 +41,14 @@ import { BpmStatusKey, BpmStatusValue } from "@budibase/shared-core"
|
|||
|
||||
const MAX_USERS_UPLOAD_LIMIT = 1000
|
||||
|
||||
const generatePassword = (length: number) => {
|
||||
const array = new Uint8Array(length)
|
||||
crypto.getRandomValues(array)
|
||||
return Array.from(array, byte => byte.toString(36).padStart(2, "0"))
|
||||
.join("")
|
||||
.slice(0, length)
|
||||
}
|
||||
|
||||
export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
||||
try {
|
||||
const currentUserId = ctx.user?._id
|
||||
|
@ -296,7 +304,7 @@ export const onboardUsers = async (
|
|||
|
||||
let createdPasswords: Record<string, string> = {}
|
||||
const users: User[] = ctx.request.body.map(invite => {
|
||||
let password = Math.random().toString(36).substring(2, 22)
|
||||
const password = generatePassword(12)
|
||||
createdPasswords[invite.email] = password
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue