Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Auth.php « modules - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e64738b637c337790d704de19f17abe164922a78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

class Piwik_Auth_Result extends Zend_Auth_Result
{
	public function __construct($code, $identity, array $messages = array())
    {
        $this->_code     = (int)$code;
        $this->_identity = $identity;
        $this->_messages = $messages;
    }
}

class Piwik_Auth extends Zend_Auth_Adapter_DbTable
{
	const SUCCESS_SUPERUSER_AUTH_CODE = 42;
	
	public function __construct()
	{
		$db = Zend_Registry::get('db');
		parent::__construct($db);
	}
	
	public function authenticate()
	{
		// we first try if the user is the super user
		
		$login = $this->_identity;
		$password = $this->_credential;
		$rootLogin = Zend_Registry::get('config')->superuser->login;
		$rootPassword = Zend_Registry::get('config')->superuser->password;
		
		if($login == $rootLogin 
			&& $password == $rootPassword)
		{
			return new Piwik_Auth_Result(Piwik_Auth::SUCCESS_SUPERUSER_AUTH_CODE, 
										$login, 
										array() // message empty
										);
		}
	
		// if not then we return the result of the database authentification provided by zend
		$this->authenticate();
	}
	
}
?>