2016-08-10 13:52:55 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Implementation of user authentication
|
|
|
|
|
*
|
|
|
|
|
* @category DMS
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @license GPL 2
|
|
|
|
|
* @version @version@
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @copyright Copyright (C) 2010-2016 Uwe Steinmann
|
|
|
|
|
* @version Release: @package_version@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
require_once "inc.ClassAuthentication.php";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Abstract class to authenticate user against ѕeeddms database
|
|
|
|
|
*
|
|
|
|
|
* @category DMS
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @copyright Copyright (C) 2010-2016 Uwe Steinmann
|
|
|
|
|
* @version Release: @package_version@
|
|
|
|
|
*/
|
|
|
|
|
class SeedDMS_DbAuthentication extends SeedDMS_Authentication {
|
|
|
|
|
|
2022-11-28 20:36:40 +00:00
|
|
|
|
var $dms;
|
|
|
|
|
|
|
|
|
|
var $settings;
|
|
|
|
|
|
|
|
|
|
public function __construct($dms, $settings) { /* {{{ */
|
|
|
|
|
$this->dms = $dms;
|
|
|
|
|
$this->settings = $settings;
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
2016-08-10 13:52:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* Do Authentication
|
|
|
|
|
*
|
|
|
|
|
* @param string $username
|
|
|
|
|
* @param string $password
|
|
|
|
|
* @return object|boolean user object if authentication was successful otherwise false
|
|
|
|
|
*/
|
|
|
|
|
public function authenticate($username, $password) { /* {{{ */
|
|
|
|
|
$dms = $this->dms;
|
|
|
|
|
|
|
|
|
|
// Try to find user with given login.
|
|
|
|
|
if($user = $dms->getUserByLogin($username)) {
|
|
|
|
|
$userid = $user->getID();
|
|
|
|
|
|
2024-03-20 16:05:41 +00:00
|
|
|
|
// Check if password matches
|
|
|
|
|
if (!seed_pass_verify($password, $user->getPwd())) {
|
|
|
|
|
$user = null;
|
|
|
|
|
}
|
|
|
|
|
} elseif(!empty($this->settings->_enableLoginByEmail) && ($user = $dms->getUserByEmail($username))) {
|
2022-11-28 20:36:40 +00:00
|
|
|
|
// Check if password matches
|
2020-07-30 08:57:29 +00:00
|
|
|
|
if (!seed_pass_verify($password, $user->getPwd())) {
|
2022-11-28 20:36:40 +00:00
|
|
|
|
$user = null;
|
2016-08-10 13:52:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $user;
|
|
|
|
|
} /* }}} */
|
|
|
|
|
}
|