Mercurial > hg > rc1
comparison plugins/password/drivers/gearman.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
| author | Charlie Root |
|---|---|
| date | Thu, 04 Jan 2018 15:50:29 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1e000243b222 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 /** | |
| 4 * Gearman Password Driver | |
| 5 * | |
| 6 * Payload is json string containing username, oldPassword and newPassword | |
| 7 * Return value is a json string saying result: true if success. | |
| 8 * | |
| 9 * @version 1.0 | |
| 10 * @author Mohammad Anwari <mdamt@mdamt.net> | |
| 11 * | |
| 12 * Copyright (C) 2005-2014, The Roundcube Dev Team | |
| 13 * | |
| 14 * This program is free software: you can redistribute it and/or modify | |
| 15 * it under the terms of the GNU General Public License as published by | |
| 16 * the Free Software Foundation, either version 3 of the License, or | |
| 17 * (at your option) any later version. | |
| 18 * | |
| 19 * This program is distributed in the hope that it will be useful, | |
| 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 22 * GNU General Public License for more details. | |
| 23 * | |
| 24 * You should have received a copy of the GNU General Public License | |
| 25 * along with this program. If not, see http://www.gnu.org/licenses/. | |
| 26 */ | |
| 27 | |
| 28 class rcube_gearman_password | |
| 29 { | |
| 30 function save($currpass, $newpass) | |
| 31 { | |
| 32 if (extension_loaded('gearman')) { | |
| 33 $rcmail = rcmail::get_instance(); | |
| 34 $user = $_SESSION['username']; | |
| 35 $payload = array( | |
| 36 'username' => $user, | |
| 37 'oldPassword' => $currpass, | |
| 38 'newPassword' => $newpass, | |
| 39 ); | |
| 40 | |
| 41 $gmc = new GearmanClient(); | |
| 42 $gmc->addServer($rcmail->config->get('password_gearman_host', 'localhost')); | |
| 43 | |
| 44 $result = $gmc->doNormal('setPassword', json_encode($payload)); | |
| 45 $success = json_decode($result); | |
| 46 | |
| 47 if ($success && $success->result == 1) { | |
| 48 return PASSWORD_SUCCESS; | |
| 49 } | |
| 50 else { | |
| 51 rcube::raise_error(array( | |
| 52 'code' => 600, | |
| 53 'type' => 'php', | |
| 54 'file' => __FILE__, 'line' => __LINE__, | |
| 55 'message' => "Password plugin: Gearman authentication failed for user $user: $error" | |
| 56 ), true, false); | |
| 57 } | |
| 58 } | |
| 59 else { | |
| 60 rcube::raise_error(array( | |
| 61 'code' => 600, | |
| 62 'type' => 'php', | |
| 63 'file' => __FILE__, 'line' => __LINE__, | |
| 64 'message' => "Password plugin: PECL Gearman module not loaded" | |
| 65 ), true, false); | |
| 66 } | |
| 67 | |
| 68 return PASSWORD_ERROR; | |
| 69 } | |
| 70 } |
