allow login by email if turned on in configuration

This commit is contained in:
Uwe Steinmann 2024-03-20 17:05:41 +01:00
parent e383f8be11
commit 0017137d0b
4 changed files with 11 additions and 0 deletions

View File

@ -47,6 +47,11 @@ class SeedDMS_DbAuthentication extends SeedDMS_Authentication {
if($user = $dms->getUserByLogin($username)) {
$userid = $user->getID();
// Check if password matches
if (!seed_pass_verify($password, $user->getPwd())) {
$user = null;
}
} elseif(!empty($this->settings->_enableLoginByEmail) && ($user = $dms->getUserByEmail($username))) {
// Check if password matches
if (!seed_pass_verify($password, $user->getPwd())) {
$user = null;

View File

@ -45,6 +45,8 @@ class Settings { /* {{{ */
var $_enableGuestLogin = false;
// If you even want guest to be logged in automatically, set the following to true
var $_enableGuestAutoLogin = false;
// If you want to allow login by email, set the following to true
var $_enableLoginByEmail = false;
// Allow users to reset their password
var $_enablePasswordForgotten = false;
// Do not allow users to change password
@ -627,6 +629,7 @@ class Settings { /* {{{ */
$tab = $node[0]->attributes();
$this->_enableGuestLogin = Settings::boolVal($tab["enableGuestLogin"]);
$this->_enableGuestAutoLogin = Settings::boolVal($tab["enableGuestAutoLogin"]);
$this->_enableLoginByEmail = Settings::boolVal($tab["enableLoginByEmail"]);
$this->_enablePasswordForgotten = Settings::boolVal($tab["enablePasswordForgotten"]);
$this->_passwordStrength = intval($tab["passwordStrength"]);
$this->_passwordStrengthAlgorithm = strval($tab["passwordStrengthAlgorithm"]);
@ -1011,6 +1014,7 @@ class Settings { /* {{{ */
$node = $this->getXMLNode($xml, '/configuration/system', 'authentication');
$this->setXMLAttributValue($node, "enableGuestLogin", $this->_enableGuestLogin);
$this->setXMLAttributValue($node, "enableGuestAutoLogin", $this->_enableGuestAutoLogin);
$this->setXMLAttributValue($node, "enableLoginByEmail", $this->_enableLoginByEmail);
$this->setXMLAttributValue($node, "enablePasswordForgotten", $this->_enablePasswordForgotten);
$this->setXMLAttributValue($node, "passwordStrength", $this->_passwordStrength);
$this->setXMLAttributValue($node, "passwordStrengthAlgorithm", $this->_passwordStrengthAlgorithm);

View File

@ -193,6 +193,7 @@ if ($action == "saveSettings")
// SETTINGS - SYSTEM - AUTHENTICATION
setBoolValue("enableGuestLogin");
setBoolValue("enableGuestAutoLogin");
setBoolValue("enableLoginByEmail");
setBoolValue("restricted");
setBoolValue("enableUserImage");
setBoolValue("disableSelfEdit");

View File

@ -479,6 +479,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
<?php $this->showConfigHeadline('settings_Authentication'); ?>
<?php $this->showConfigCheckbox('settings_enableGuestLogin', 'enableGuestLogin'); ?>
<?php $this->showConfigCheckbox('settings_enableGuestAutoLogin', 'enableGuestAutoLogin'); ?>
<?php $this->showConfigCheckbox('settings_enableLoginByEmail', 'enableLoginByEmail'); ?>
<?php $this->showConfigCheckbox('settings_restricted', 'restricted'); ?>
<?php $this->showConfigCheckbox('settings_enableUserImage', 'enableUserImage'); ?>
<?php $this->showConfigCheckbox('settings_disableSelfEdit', 'disableSelfEdit'); ?>