aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/LoginManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/LoginManager.php')
-rw-r--r--application/LoginManager.php28
1 files changed, 13 insertions, 15 deletions
diff --git a/application/LoginManager.php b/application/LoginManager.php
index 347fb3b9..5ce836fa 100644
--- a/application/LoginManager.php
+++ b/application/LoginManager.php
@@ -48,15 +48,15 @@ class LoginManager
48 /** 48 /**
49 * Check user session state and validity (expiration) 49 * Check user session state and validity (expiration)
50 * 50 *
51 * @param array $server The $_SERVER array 51 * @param array $session The $_SESSION array (reference)
52 * @param array $session The $_SESSION array (reference) 52 * @param array $cookie The $_COOKIE array
53 * @param array $cookie The $_COOKIE array 53 * @param string $webPath Path on the server in which the cookie will be available on
54 * @param string $webPath Path on the server in which the cookie will be available on 54 * @param string $clientIpId Client IP address identifier
55 * @param string $token Session token 55 * @param string $token Session token
56 * 56 *
57 * @return bool true if the user session is valid, false otherwise 57 * @return bool true if the user session is valid, false otherwise
58 */ 58 */
59 public function checkLoginState($server, & $session, $cookie, $webPath, $token) 59 public function checkLoginState(& $session, $cookie, $webPath, $clientIpId, $token)
60 { 60 {
61 if (! $this->configManager->exists('credentials.login')) { 61 if (! $this->configManager->exists('credentials.login')) {
62 // Shaarli is not configured yet 62 // Shaarli is not configured yet
@@ -64,8 +64,6 @@ class LoginManager
64 return; 64 return;
65 } 65 }
66 66
67 $clientIpId = client_ip_id($server);
68
69 if (isset($cookie[SessionManager::$LOGGED_IN_COOKIE]) 67 if (isset($cookie[SessionManager::$LOGGED_IN_COOKIE])
70 && $cookie[SessionManager::$LOGGED_IN_COOKIE] === $token 68 && $cookie[SessionManager::$LOGGED_IN_COOKIE] === $token
71 ) { 69 ) {
@@ -100,13 +98,14 @@ class LoginManager
100 /** 98 /**
101 * Check user credentials are valid 99 * Check user credentials are valid
102 * 100 *
103 * @param array $server The $_SERVER array 101 * @param string $remoteIp Remote client IP address
104 * @param string $login Username 102 * @param string $clientIpId Client IP address identifier
105 * @param string $password Password 103 * @param string $login Username
104 * @param string $password Password
106 * 105 *
107 * @return bool true if the provided credentials are valid, false otherwise 106 * @return bool true if the provided credentials are valid, false otherwise
108 */ 107 */
109 public function checkCredentials($server, $login, $password) 108 public function checkCredentials($remoteIp, $clientIpId, $login, $password)
110 { 109 {
111 $hash = sha1($password . $login . $this->configManager->get('credentials.salt')); 110 $hash = sha1($password . $login . $this->configManager->get('credentials.salt'));
112 111
@@ -115,17 +114,16 @@ class LoginManager
115 ) { 114 ) {
116 logm( 115 logm(
117 $this->configManager->get('resource.log'), 116 $this->configManager->get('resource.log'),
118 $server['REMOTE_ADDR'], 117 $remoteIp,
119 'Login failed for user ' . $login 118 'Login failed for user ' . $login
120 ); 119 );
121 return false; 120 return false;
122 } 121 }
123 122
124 $clientIpId = client_ip_id($server);
125 $this->sessionManager->storeLoginInfo($clientIpId); 123 $this->sessionManager->storeLoginInfo($clientIpId);
126 logm( 124 logm(
127 $this->configManager->get('resource.log'), 125 $this->configManager->get('resource.log'),
128 $server['REMOTE_ADDR'], 126 $remoteIp,
129 'Login successful' 127 'Login successful'
130 ); 128 );
131 return true; 129 return true;