From 5a704f2717be7a913551f0f2e46127ac1c8dd2c3 Mon Sep 17 00:00:00 2001 From: Boris Gulay Date: Fri, 20 May 2016 23:40:48 +0300 Subject: [PATCH] Fixed double encryption of pwd when changing record (cannot connect after change). --- ident_switch.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ident_switch.php b/ident_switch.php index be9b96e..81af553 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -232,7 +232,7 @@ class ident_switch extends rcube_plugin return $args; } - $sql = 'SELECT NULL FROM ' . $rc->db->table_name($this->table) . ' WHERE iid = ? AND user_id = ?'; + $sql = 'SELECT password FROM ' . $rc->db->table_name($this->table) . ' WHERE iid = ? AND user_id = ?'; $q = $rc->db->query($sql, $args['id'], $rc->user->ID); $r = $rc->db->fetch_assoc($q); if ($r) @@ -255,6 +255,10 @@ class ident_switch extends rcube_plugin if (get_input_value('_ident_switch_form_secure', RCUBE_INPUT_POST)) $flags |= $this->db_secure; + // Do we need to update pwd? + $fPass = get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST); + if ($fPass != $r['password']) + $fPass = $rc->encrypt($fPass); $rc->db->query( $sql, @@ -263,7 +267,7 @@ class ident_switch extends rcube_plugin $fHost, $fPort, $fUser, - $rc->encrypt(get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST)), + $fPass, $fDelim, $rc->user->ID, $args['id']