DatabaseAuth.class.php (834B)
1 <?php 2 3 use database\Database; 4 5 /** 6 * Authentifzierung über eine externe Datenbank. 7 * @author dankert 8 * 9 */ 10 class DatabaseAuth implements Auth 11 { 12 13 /** 14 * Login. 15 */ 16 public function login( $user, $password, $token ) 17 { 18 global $conf; 19 20 $authDbConf = $conf['security']['authdb']; 21 22 if ( ! $authDbConf['enable'] ) 23 return false; 24 25 $authdb = new Database( $authDbConf ); 26 27 $sql = $authdb->sql( $conf['security']['authdb']['sql'] ); 28 $algo = $authdb->sql( $conf['security']['authdb']['hash_algo'] ); 29 $sql->setString('username',$user ); 30 $sql->setString('password',hash($algo,$password)); 31 $row = $sql->getRow(); 32 $ok = !empty($row); 33 34 // noch nicht implementiert: $authdb->close(); 35 36 return $ok?OR_AUTH_STATUS_SUCCESS:OR_AUTH_STATUS_FAILED; 37 } 38 39 public function username() 40 { 41 return null; 42 } 43 44 } 45 46 ?>