Improve code redability 2
This commit is contained in:
@@ -152,15 +152,11 @@ const logout = async function (req, res) {
|
||||
}
|
||||
|
||||
// Util function for generating new random password for users.
|
||||
// TODO: Probably we can do someting better here.
|
||||
function generatePassword() {
|
||||
var length = 8,
|
||||
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
||||
retVal = "";
|
||||
for (var i = 0, n = charset.length; i < length; ++i) {
|
||||
retVal += charset.charAt(Math.floor(Math.random() * n));
|
||||
}
|
||||
return retVal;
|
||||
function generatePassword(length = 12) {
|
||||
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+";
|
||||
return Array.from(crypto.randomFillSync(new Uint8Array(length)))
|
||||
.map((x) => charset[x % charset.length])
|
||||
.join("");
|
||||
}
|
||||
|
||||
const resetPassword = async function (req, res) {
|
||||
|
||||
Reference in New Issue
Block a user