This is my first attempt at serious drupal hacking.
I tried it on drupal 5.7, I can possibly port this to drupal6, but I probably need a bit of help with code guidelines.

What this patch does is extend the password validator in form.inc to add a checkbox (autogenerate password) that will generate the password. It works, but there are a few details unclear to me.

  • I'm unsure how to pass options to a password confirm. So far, I simply set #autogen if I wanted an autogen checkbox.
  • I had to move the user_password() function code in there, because I'm uncertain I can use a user.module function from an include file. I left a stub that calls the new function in the user.module. I don't know about naming conventions.
  • I haven't figured out how to recover more than a simple value from the password confirm (like, whether the password was autogenerated or not), so I just add the new password value to the message presented to the admin if email confirmation is not set.
  • There's a new untranslated string.
  • I don't know how to do this with external modules and hooks, which is why I present this as a patch to core.

I am definitely going to use this on a site (where I have an assistant who has to create about 100 accounts each year, where users do not create their own accounts, and where just simplifying this makes sense...)

CommentFileSizeAuthor
d.patch4.48 KBespie

Comments

dries’s picture

Version: 5.7 » 7.x-dev
Status: Needs review » Needs work

While this looks like an interesting feature request, the code will need some more. No need to duplicate the password function, and please use the Drupal code conventions. I'd be happy to help out more after you read those. :)

Last but not least, new features should be committed against the Drupal 7 development branch (CVS HEAD) -- Drupal 5.7 is frozen. No new features go into Drupal 5.7.

mianghe’s picture

thanks espie,

I test your code in 6.3 and it works perfectly. I think that a experienced Drupal's programmer can develop a contrib module easily.

alexmoreno’s picture

interesting path, im also going to use on a web. Is it possible to commit this as a project itself?

Regards

sun.core’s picture

Version: 7.x-dev » 8.x-dev
achton’s picture

Subscribing, though mostly while I figure out if this turned into a contrib module or not. In any case, I think it is a valid feature, though perhaps not in core.

It particularly fits use cases where a host of corporate users are created regularly and the admin wants to give them random passwords initially.

jhedstrom’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)

Marking as a duplicate of the issues mentioned in #6. There is also https://www.drupal.org/project/genpass in contrib (will need porting to 8).