File: Horde.php

package info (click to toggle)
php-horde-passwd 5.0.2-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 3,324 kB
  • ctags: 301
  • sloc: php: 2,014; xml: 1,054; makefile: 10; sh: 3
file content (54 lines) | stat: -rw-r--r-- 1,612 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
 * Copyright 2011-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @category  Horde
 * @copyright 2011-2014 Horde LLC
 * @license   http://www.horde.org/licenses/gpl GPL
 * @package   Passwd
 */

/**
 * The Horde driver attempts to change a user's password without
 * caring about the actual implementation.
 *
 * It relies on the current horde authentication mechanism's ability to update
 * the user.
 *
 * @author    Ralf Lang <lang@b1-systems.de>
 * @category  Horde
 * @copyright 2011-2014 Horde LLC
 * @license   http://www.horde.org/licenses/gpl GPL
 * @package   Passwd
 */
class Passwd_Driver_Horde extends Passwd_Driver
{
    /**
     */
    protected function _changePassword($user, $oldpass, $newpass)
    {
        $auth = $this->_params['auth'];

        if (!$auth->hasCapability('update')) {
            throw new Passwd_Exception(_("The current horde configuration does not allow changing passwords."));
        }

        /* Check the provided old password. */
        try {
            if ($auth->authenticate($user, array('password' => $oldpass, false))) {
                /* Actually modify the password. */
                $auth->updateUser($user, $user, array(
                    'password' => $newpass
                ));
            } else {
                throw new Passwd_Exception(_("Incorrect old password."));
            }
        } catch (Horde_Auth_Exception $e) {
            throw new Passwd_Exception($e);
        }
    }

}