[Koha] Changing the way passwords are entered in the staff client

MJ Ray mjr at phonecoop.coop
Sat Oct 8 07:29:06 NZDT 2011


Owen Leonard <oleonard at myacpl.org>
> There is an open bug report
> (http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5280)
[...]
> The problem is that this doesn't work with the feature which suggests
> a random password: "Below is a randomly generated suggestion." We
> can't offer to give the patron a randomly-generated password if we
> aren't able to tell them what it is when we're assigning it.
> 
> I'm asking for opinions: Is the random password feature something we
> can give up?

I could give it up BUT why would we need to?

A cool thing I've seen on dtc (package dtc-common) in debian is a
button next to the password field that uses javascript to fill it
with random characters and change it to type="text" so you can
read it.  The actual password could be generated by the perl
script.  dtc's code boils down to:

function dtc_gen_passwd(frm_name,fld_name){
	document[frm_name][fld_name].value = 'smpc9cf98dzy';
	var curObj = document[frm_name][fld_name];
	try {
		document[frm_name][fld_name].type = 'text';
	} catch (e) {
// type property read only on IE at the time of this writing,
// so replace the control with a new one
		if (curObj.getAttribute('type') != 'text') {
			var newObj=document.createElement('input');
			newObj.setAttribute('type','text');
			newObj.setAttribute('name',curObj.getAttribute('name'));
			newObj.setAttribute('class',curObj.getAttribute('class'));
			newObj.value = curObj.value;
			curObj.parentNode.replaceChild(newObj, curObj);
		}
	}
}

and it's then called from the generate button with somethng like
onClick="dtc_gen_passwd('addnewuser_frm','newadmin_pass');"

AFAIK the above is Copyright: (C) 2001-2008, Thomas Goirand <thomas at goirand.fr>
	(C) 2001-2008, Damien Mascord <tusker at tusker.org>
	(C) 2003-2008, GPLHost LLC <info at gplhost.com>
License: LGPL-2

Maybe there's a smarter way to do that with the js libs and maybe
generating the password in the javascript, but I offer it as an idea.

Who'd've thunk it? Me suggesting using more javascript.

Hope that helps,
-- 
MJ Ray (slef), member of www.software.coop, a for-more-than-profit co-op.
http://koha-community.org supporter, web and LMS developer, statistician.
In My Opinion Only: see http://mjr.towers.org.uk/email.html
Available for hire for Koha work http://www.software.coop/products/koha


More information about the Koha mailing list