File modules/cms/auth/DatabaseAuth.class.php

Last commit: Mon Nov 30 11:17:56 2020 +0100	Jan Dankert	Fix: DatabaseAuth should only use the Auth::STATUS_* constants as return value.
1 <?php 2 3 namespace cms\auth; 4 5 use cms\base\Configuration; 6 use database\Database; 7 8 /** 9 * Authentifzierung über eine externe Datenbank. 10 * @author dankert 11 * 12 */ 13 class DatabaseAuth implements Auth 14 { 15 16 /** 17 * Login. 18 */ 19 public function login($user, $password, $token) 20 { 21 $authDbConf = Configuration::subset(['security','authdb']); 22 23 if (!$authDbConf->is('enable',true)) 24 return Auth::STATUS_FAILED; 25 26 $authdb = new Database($authDbConf); 27 28 $sql = $authdb->sql($authDbConf->get('sql')); 29 $algo = $authDbConf->get('hash_algo' ); 30 $sql->setString('username', $user); 31 $sql->setString('password', hash($algo, $password)); 32 $row = $sql->getRow(); 33 34 $authdb->disconnect(); 35 36 return $row ? Auth::STATUS_SUCCESS : Auth::STATUS_FAILED; 37 } 38 39 public function username() 40 { 41 return null; 42 } 43 44 }
Download modules/cms/auth/DatabaseAuth.class.php
History Mon, 30 Nov 2020 11:17:56 +0100 Jan Dankert Fix: DatabaseAuth should only use the Auth::STATUS_* constants as return value. Mon, 16 Nov 2020 13:21:57 +0100 Jan Dankert Code cleanup: Externalize calling the auth modules. Sun, 1 Nov 2020 03:08:55 +0100 Jan Dankert Replaced the calls to "Configuration::rawConfig()" with the OO style calls; Cleanup LoginAction. Tue, 29 Sep 2020 21:34:01 +0200 Jan Dankert Refactoring: Do not use global constants. Sat, 26 Sep 2020 10:32:02 +0200 Jan Dankert Refactoring: No global $conf array any more. Sun, 23 Feb 2020 04:49:34 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 2. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.