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:
committed by
GitHub
parent
cd1ca7c039
commit
a04b24a5d5
@@ -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("");
|
||||
|
||||
Reference in New Issue
Block a user