Skip to content

Commit

Permalink
fix for issue #18
Browse files Browse the repository at this point in the history
  • Loading branch information
lautaroangelico committed Feb 2, 2018
1 parent c375c36 commit 048b6fc
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions includes/classes/class.login.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
/**
* WebEngine
* http://muengine.net/
* WebEngine CMS
* https://webenginecms.org/
*
* @version 1.0.9
* @author Lautaro Angelico <http://lautaroangelico.com/>
* @copyright (c) 2013-2017 Lautaro Angelico, All Rights Reserved
* @version 1.0.9.9
* @author Lautaro Angelico <https://lautaroangelico.com/>
* @copyright (c) 2013-2018 Lautaro Angelico, All Rights Reserved
*
* Licensed under the MIT license
* http://opensource.org/licenses/MIT
* https://opensource.org/licenses/MIT
*/

class login {
Expand Down Expand Up @@ -63,17 +63,24 @@ public function validateLogin($username, $password) {
if(!$this->canLogin($_SERVER['REMOTE_ADDR'])) throw new Exception(lang('error_3',true));
if(!$this->common->userExists($username)) throw new Exception(lang('error_2',true));
if($this->common->validateUser($username,$password)) {

$userId = $this->common->retrieveUserID($username);
if(!check_value($userId)) throw new Exception(lang('error_12',true));

$accountData = $this->common->accountInformation($userId);
if(!is_array($accountData)) throw new Exception(lang('error_12',true));

# login success
$this->removeFailedLogins($_SERVER['REMOTE_ADDR']);
session_regenerate_id();
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['userid'] = $this->common->retrieveUserID($username);
$_SESSION['username'] = $username;
$_SESSION['userid'] = $userId;
$_SESSION['username'] = $accountData[_CLMN_USERNM_];

// ACTIVE SESSIONS
$this->deleteActiveSession($_SESSION['userid']);
$this->addActiveSession($_SESSION['userid'], $_SERVER['REMOTE_ADDR']);
$this->deleteActiveSession($userId);
$this->addActiveSession($userId, $_SERVER['REMOTE_ADDR']);

# redirect to usercp
redirect(1,'usercp/');
Expand Down

0 comments on commit 048b6fc

Please sign in to comment.