Roundcube Community Forum

 

Change password postfix+courier+mysql

Started by polinoma, November 04, 2006, 09:15:28 AM

Previous topic - Next topic

polinoma

It's a nice way to change password /http://postfix.pentachron.net/.

If you want, you can patch roundcube a bit so that your users can change their password in their user preferences. To do so edit the following two files:

First, open 'roundcube/program/steps/settings/func.inc' and search for 'function rcmail_user_prefs_form', then scroll down to the end of this function and add the following code before ' $out .= "\n$form_end";'

// CCC addition
 // show password form
 $field_id = 'rcmfd_password';
 $input_password = new textfield(array('name' => '_password', 'id' => $field_id, 'size' => 20));

 $out .= sprintf("%s (empty = unchanged)\n",
         $field_id,
         rep_specialchars_output(rcube_label('password')),
         $input_password->show($CONFIG['password']));
// end CCC addition

Then open 'roundcube/program/steps/settings/save_prefs.inc' and insert the following after the line "$a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE;":

// CCC addition
if ($_POST['_password'] != "")
{
  mysql_query("UPDATE ccc.emails SET password = '".$_POST['_password']."' WHERE concat(account, '@', domain) = '".$_SESSION['username']."'")
    or die(mysql_error());
  $_SESSION['password'] = encrypt_passwd($_POST['_password']);
}
// end of CCC addition

Notice: change ccc.emails to yourdatabase.emails if needed!

Notice: the roundcubemail mysql user needs update permissions for the email table!


deejmer

I appreciate the post....this is exactly what I'm looking for.....Pardon me, but I'm a total neub and need to ask a clarifying (probably dumb) question:

you say:
QuoteNotice: change ccc.emails to yourdatabase.emails if needed!
Notice: the roundcubemail mysql user needs update permissions for the email table!

I changed my code in the two files as instructed, and the new PW change field does show in Preferences, but when I attempt to change the password, the app says that I dont have update permissions to the email table. When I look at my DB for roundcubemail in phpmyadmin, i do not see an emails table. Am I missing something? Is this outside of the roundcube DB?

If you can clarify, I'd really appreciate it.

Thanks in advance!

CReber

It doesn't work in an existing roundcube system, right? What do I need that it works? Can you make a detailled tutorial on that?

bswinnerton



Le Veilleur

Quote from: Julien I wrote a pacth to do this a few months ago : http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
Very Nice work, I'll try it with the RC2 this evening.

Le Veilleur

Quote from: Julien I wrote a pacth to do this a few months ago : http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
There is a bug in your mod. The link to the passwd page doesn't work. Exactly the same problem that's explain in your blog's comments

stefan-becker

Can I use this patch with Plesk from SWSoft?

Julien

Quote from: Le Veilleur
Quote from: Julien I wrote a pacth to do this a few months ago : http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
There is a bug in your mod. The link to the passwd page doesn't work. Exactly the same problem that's explain in your blog's comments

My patch works with RC1. I've not yet tested it with RC2. It will be done quickly. Stay in touch.

Dexterp37

Hello there, I just wanted to tell you that I slightly modified your code to make it work for RC2. Works smoothly ;)

Aproximately near line 29 in file "program\steps\settings\save_prefs.inc", there is a block where an array is declared. It starts with "$a_user_prefs = array(". Just add the following line under the "'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE," line

 // Password MOD
 'password' => isset($_POST['_password']) ? TRUE : FALSE,
 // End Password MOD

Now just AFTER the "foreach ((array)$CONFIG['dont_override'] as $p) ..." near line 39, add the block which handles password saving to DB

// Password MOD
if (isset($_POST['_password']))
{
  $tmpEncPass = YourEncryptionFunctionHERE($_POST['_password'], "");
 
 
  mysql_query("UPDATE CCC.TableWithPasswordHERE SET password = '".$tmpEncPass."' WHERE username = '".$_SESSION['username']."'")
    or die(mysql_error());

  $_SESSION['password'] = encrypt_passwd($_POST['_password']);
}
// End Password MOD

Now in "program\steps\settings\func.inc", around line 200, there is some code like "$out .= "\n$form_end";". Just BEFORE this line, add the following block:

 // Password MOD
 $field_id = 'rcmfd_password';
 $input_password = new textfield(array('name' => '_password', 'id' => $field_id, 'size' => 20));

 $out .= sprintf("%s (empty = unchanged)\n",
         $field_id,
         rep_specialchars_output(rcube_label('password')),
         $input_password->show($CONFIG['password']));
 // End Password MOD

It should work :) One problem I'm experiencing is that the field is not empty when Preferences menu is opened, it has a "1" in it.

Dexterp37

Little update: instead of passing $CONFIG['password'] as a parameter for the show function, remove it from function parameters so that the show call looks like this:

$input_password->show()

This is needed to prevent users to erroneously change their password because field has a '1' in it.

rockwilda

Does this work with rc 0.1 stable?

Is there a patch file?

best regards,
Nico

Dexterp37

I don't know yet, didn't had a chance to test. Will do soon, a release a patch in case :)

Dexterp37

I just applied this mod to 0.1stable, and it works flawlessly. I've attached the patch to this post. Let me know if it works, that's my first patch!




rockwilda

Hey thanks for your patch file! But I'm unable to unzip it ... tried it with linux and windows ...