some restructuring to support password reset page
This commit is contained in:
parent
37a9fd2831
commit
294d25f65c
|
@ -39,7 +39,7 @@ $Id$
|
||||||
*/
|
*/
|
||||||
class asteriskAccount extends baseModule implements passwordService {
|
class asteriskAccount extends baseModule implements passwordService {
|
||||||
|
|
||||||
private $asteriskDefaultRealm = "asterisk";
|
const ASTERISK_DEFAULT_REALM = "asterisk";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new asteriskAccount object.
|
* Creates a new asteriskAccount object.
|
||||||
|
@ -337,7 +337,9 @@ class asteriskAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
//add password
|
//add password
|
||||||
if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']] != "") {
|
if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']] != "") {
|
||||||
$partialAccounts[$i]['AstAccountRealmedPassword'] = $this->hashPassword($rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']]);
|
$attributes = array('AstAccountCallerID' => array($partialAccounts[$i]['AstAccountCallerID'])); // fake attribute list for password building
|
||||||
|
$pwdString = asteriskAccount::buildPasswordString($attributes, $this->moduleSettings, $rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']]);
|
||||||
|
$partialAccounts[$i]['AstAccountRealmedPassword'] = $pwdString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $messages;
|
return $messages;
|
||||||
|
@ -372,25 +374,26 @@ class asteriskAccount extends baseModule implements passwordService {
|
||||||
if (!in_array(get_class($this), $modules)) {
|
if (!in_array(get_class($this), $modules)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$astRealm = $this->asteriskDefaultRealm;
|
$this->attributes['AstAccountRealmedPassword'][0] = asteriskAccount::buildPasswordString($this->attributes, $this->moduleSettings, $password);
|
||||||
if ($this->get_scope()=='user') {
|
|
||||||
$asteriskRealmFromProfile = $this->moduleSettings['asteriskAccount_AsteriskRealm'][0];
|
|
||||||
if ($asteriskRealmFromProfile != ""){
|
|
||||||
$astRealm = $asteriskRealmFromProfile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$password_con = $this->attributes['AstAccountCallerID'][0] . ":" . $astRealm . ":" . $password;
|
|
||||||
$this->attributes['AstAccountRealmedPassword'][0] = $this->hashPassword($password_con);
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function buildPasswordString(&$attributes, &$moduleSettings, $password) {
|
||||||
|
$astRealm = asteriskAccount::ASTERISK_DEFAULT_REALM;
|
||||||
|
$asteriskRealmFromProfile = $moduleSettings['asteriskAccount_AsteriskRealm'][0];
|
||||||
|
if ($asteriskRealmFromProfile != ""){
|
||||||
|
$astRealm = $asteriskRealmFromProfile;
|
||||||
|
}
|
||||||
|
return asteriskAccount::hashPassword($attributes['AstAccountCallerID'][0] . ":" . $astRealm . ":" . $password);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashes a password value to Asterisk format.
|
* Hashes a password value to Asterisk format.
|
||||||
*
|
*
|
||||||
* @param String $password password
|
* @param String $password password
|
||||||
* @return String hash
|
* @return String hash
|
||||||
*/
|
*/
|
||||||
private function hashPassword($password) {
|
private static function hashPassword($password) {
|
||||||
return "{MD5}" . md5($password);
|
return "{MD5}" . md5($password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue