swap out random password method

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-17 10:22:30 +02:00
parent 7a0c6366f7
commit 8e3bd36cc5
1 changed files with 1 additions and 19 deletions

View File

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