swap out random password method

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-17 10:22:30 +02:00
parent 0b89117225
commit 3c58559763
1 changed files with 1 additions and 19 deletions

View File

@ -4,25 +4,7 @@
import { users } from "stores/portal"
const [email, error, touched] = createValidationStore("", emailValidator)
const password = generatePassword()
function generatePassword() {
return Array(30)
.fill(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$"
)
.map(
x =>
x[
Math.floor(
(crypto.getRandomValues(new Uint32Array(1))[0] /
(0xffffffff + 1)) *
x.length
)
]
)
.join("")
}
const password = Math.random().toString(36).substr(2, 20)
async function createUser() {
const res = await users.create({ email: $email, password })