mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
update utils.js
generate random password
This commit is contained in:
@@ -1224,12 +1224,34 @@ export const Utils = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
generatePassword: function(passwordLength) {
|
generatePassword: function(length, hasNum=1, hasChar=1, hasSymbol=1) {
|
||||||
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789';
|
|
||||||
let password = '';
|
var password = "";
|
||||||
for (let i = 0; i < passwordLength; i++) {
|
|
||||||
password += possible.charAt(Math.floor(Math.random() * possible.length));
|
// 65~90:A~Z
|
||||||
|
password += String.fromCharCode(Math.floor((Math.random() * (90-65)) + 65));
|
||||||
|
|
||||||
|
// 97~122:a~z
|
||||||
|
password += String.fromCharCode(Math.floor((Math.random() * (122-97)) + 97));
|
||||||
|
|
||||||
|
// 48~57:0~9
|
||||||
|
password += String.fromCharCode(Math.floor((Math.random() * (57-48)) + 48));
|
||||||
|
|
||||||
|
// 33~47:!~/
|
||||||
|
password += String.fromCharCode(Math.floor((Math.random() * (47-33)) + 33));
|
||||||
|
|
||||||
|
// 33~47:!~/
|
||||||
|
// 48~57:0~9
|
||||||
|
// 58~64::~@
|
||||||
|
// 65~90:A~Z
|
||||||
|
// 91~96:[~`
|
||||||
|
// 97~122:a~z
|
||||||
|
// 123~127:{~
|
||||||
|
for (var i = 0; i <= length-4; i++) {
|
||||||
|
var num = Math.floor((Math.random() * (127-33)) + 33);
|
||||||
|
password += String.fromCharCode(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
return password;
|
return password;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1386,7 +1408,7 @@ export const Utils = {
|
|||||||
onKeyDown: function(e) {
|
onKeyDown: function(e) {
|
||||||
if (e.key == 'Enter' || e.key == 'Space') {
|
if (e.key == 'Enter' || e.key == 'Space') {
|
||||||
e.target.click();
|
e.target.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user