1/ In users object add a text field called "autogenerated password"
in the following example field ID is #field_10.
2/ Create a form based on users
with at least name and email + the autogenerated password : in the following example the form ID is #view_20.
3/ in the form rule / record rule
create the following rule :
Update this record
Set "password" to "a form value", "autogenerated password"
4/ Create an email rule
"send a custom email"
send "to" "an email field" "Email"
write your text and select the field from the left hand list:
your ID: {Email}
your password: {Auto generated password}
5/ Add the following codes to API and code / Javascript
this function generates the random PW
/*Generate random password*/$.generateRandomPassword = function(limit) {
limit = limit || 8;
var password = ‘’;
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789><!"$%&/()=?#_-@+’;
var list = chars.split(’’);
var len = list.length, i = 0;
do {
i++;
var index = Math.floor(Math.random() * len);
password += list[index];
} while(i < limit);
return password;
};
and then the following to call the function and disable the field to prevent the autogenerated PW to be modified in the form.
/ generates random PW in the form and disable the field to prevent modification*/$(document).on(‘knack-view-render.view_20’, function (event, view, data) {
var pwd = $.generateRandomPassword(8);
$(’#field_10’).val(pwd).prop(‘disabled’, true);
});
5/ Add the following codes to API and code / CSS
To grant confidentiality of the auto generated PW this will replace the PW characters by dots in your interface.
/* replace the PW characters by dots */#field_10 {
-webkit-text-security: disc;
}