return md5(implode(',' , array($month, $this->email , $this->passwd, $this->id)));
}
+
+ function checkTwoFactorAuthentication($val)
+ {
+ require_once 'System.php';
+
+ $oathtool = System::which('oathtool');
+
+ if (!$oathtool) {
+ return false;
+ }
+
+ $cmd = "{$oathtool} --totp --base32 {$this->oath_key}";
+
+ $password = exec($cmd);
+
+ return ($password == $val) ? true : false;
+ }
+
function checkPassword($val)
{
if (substr($this->passwd,0,1) == '$') {
}
/*
- * Seems we never expose oath_key, so...
+ * Seems we never expose oath_key / passwd, so...
*/
+
+ $this->_extra_cols = array('length_passwd', 'length_oath_key');
+
$this->selectAdd("
- CASE WHEN core_person.oath_key != '' THEN
- TRUE
- ELSE
- FALSE
- END AS has_oath_key
+ LENGTH({$this->tableName()}.passwd) AS length_passwd,
+ LENGTH({$this->tableName()}.oath_key) AS length_oath_key
");
}
return true;
}
- function toRooSingleArray($au, $q)
- {
- $ret = $this->toArray();
-
- $core_person = DB_DataObject::factory('core_person');
- $core_person->selectAdd('core_person.oath_key AS oath_key');
- $core_person->get($this->id);
-
- $ret['has_oath_key'] = (empty($core_person->oath_key)) ? 0 : 1;
-
- return $ret;
-
- }
-
function beforeUpdate($old, $q, $roo)
{
if(!empty($q['_generate_oath_key'])){
return "data:image/png;base64,{$base64}";
}
- function checkTwoFactorAuthentication($val)
- {
- require_once 'System.php';
-
- $oathtool = System::which('oathtool');
-
- if (!$oathtool) {
- return false;
- }
-
- $cmd = "{$oathtool} --totp --base32 {$this->oath_key}";
-
- $password = exec($cmd);
-
- return ($password == $val) ? true : false;
- }
-
}