ILIAS  release_8 Revision v8.24
class.ilAuthProviderDatabase.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
31 public function doAuthentication(ilAuthStatus $status): bool
32 {
36 $user = ilObjectFactory::getInstanceByObjId(ilObjUser::_loginExists($this->getCredentials()->getUsername()), false);
37
38 $this->getLogger()->debug('Trying to authenticate user: ' . $this->getCredentials()->getUsername());
39 if ($user instanceof ilObjUser) {
40 if ($user->getId() === ANONYMOUS_USER_ID) {
41 $this->getLogger()->notice('Failed authentication for anonymous user id. ');
42 $this->handleAuthenticationFail($status, 'err_wrong_login');
43 return false;
44 }
45 if (!ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))) {
46 $this->getLogger()->debug('DB authentication failed: current user auth mode does not allow local validation.');
47 $this->getLogger()->debug('User auth mode: ' . $user->getAuthMode(true));
48 $this->handleAuthenticationFail($status, 'err_wrong_login');
49 return false;
50 }
51 if (ilUserPasswordManager::getInstance()->verifyPassword($user, $this->getCredentials()->getPassword())) {
52 $this->getLogger()->debug('Successfully authenticated user: ' . $this->getCredentials()->getUsername());
54 $status->setAuthenticatedUserId($user->getId());
55 return true;
56 }
57 }
58 $this->handleAuthenticationFail($status, 'err_wrong_login');
59 return false;
60 }
61}
Base class for authentication providers (ldap, apache, ...)
getLogger()
Get logger.
handleAuthenticationFail(ilAuthStatus $status, string $a_reason)
Handle failed authentication.
Auth status implementation.
static isLocalPasswordEnabledForAuthMode($a_authmode)
Check if local password validation is enabled for a specific auth_mode.
User class.
static _loginExists(string $a_login, int $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance()
Singleton method to reduce footprint (included files, created instances)
const ANONYMOUS_USER_ID
Definition: constants.php:27
doAuthentication(\ilAuthStatus $status)
Do authentication.