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
|
export let showOnboardingTypeModal
|
||||||
|
|
||||||
const password = Math.random().toString(36).substring(2, 22)
|
const password = generatePassword(12)
|
||||||
let disabled
|
let disabled
|
||||||
let userGroups = []
|
let userGroups = []
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
{
|
{
|
||||||
email: "",
|
email: "",
|
||||||
role: "appUser",
|
role: "appUser",
|
||||||
password: Math.random().toString(36).substring(2, 22),
|
password: generatePassword(12),
|
||||||
forceResetPassword: true,
|
forceResetPassword: true,
|
||||||
error: null,
|
error: null,
|
||||||
},
|
},
|
||||||
|
@ -69,6 +69,14 @@
|
||||||
return userData[index].error == null
|
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 = () => {
|
const onConfirm = () => {
|
||||||
let valid = true
|
let valid = true
|
||||||
userData.forEach((input, index) => {
|
userData.forEach((input, index) => {
|
||||||
|
|
|
@ -216,7 +216,7 @@
|
||||||
const newUser = {
|
const newUser = {
|
||||||
email: email,
|
email: email,
|
||||||
role: usersRole,
|
role: usersRole,
|
||||||
password: Math.random().toString(36).substring(2, 22),
|
password: generatePassword(12),
|
||||||
forceResetPassword: true,
|
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 () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
await groups.actions.init()
|
await groups.actions.init()
|
||||||
|
|
|
@ -41,6 +41,14 @@ import { BpmStatusKey, BpmStatusValue } from "@budibase/shared-core"
|
||||||
|
|
||||||
const MAX_USERS_UPLOAD_LIMIT = 1000
|
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>) => {
|
export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
||||||
try {
|
try {
|
||||||
const currentUserId = ctx.user?._id
|
const currentUserId = ctx.user?._id
|
||||||
|
@ -296,7 +304,7 @@ export const onboardUsers = async (
|
||||||
|
|
||||||
let createdPasswords: Record<string, string> = {}
|
let createdPasswords: Record<string, string> = {}
|
||||||
const users: User[] = ctx.request.body.map(invite => {
|
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
|
createdPasswords[invite.email] = password
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue