add random password generation on user create/edit form (#123)

* Add button to generate password in UserEdit

* increase default random password length to 64, add more possible symbols to the generator

* update readme
This commit is contained in:
Borislav Pantaleev
2024-11-06 11:48:44 +02:00
committed by GitHub
parent cd1ca7c039
commit a04b24a5d5
11 changed files with 41 additions and 4 deletions

View File

@@ -91,8 +91,8 @@ export function returnMXID(input: string | Identifier): string {
* Generate a random user password
* @returns a new random password as string
*/
export function generateRandomPassword(length = 20): string {
const characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$";
export function generateRandomPassword(length = 64): string {
const characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()_-+={[}]|:;'.?/<>,";
return Array.from(crypto.getRandomValues(new Uint32Array(length)))
.map(x => characters[x % characters.length])
.join("");