bludit/bl-kernel/admin/controllers/login.php

54 lines
1.6 KiB
PHP
Raw Normal View History

2015-03-27 02:00:01 +01:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-08-03 02:49:12 +02:00
// ============================================================================
// Check role
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
2017-07-16 00:42:37 +02:00
function checkLogin($args)
2015-08-18 04:02:19 +02:00
{
global $Security;
global $Login;
global $Language;
2017-07-16 00:42:37 +02:00
if ($Security->isBlocked()) {
2015-08-18 04:02:19 +02:00
Alert::set($Language->g('IP address has been blocked').'<br>'.$Language->g('Try again in a few minutes'));
return false;
}
2017-07-16 00:42:37 +02:00
if ($Login->verifyUser($_POST['username'], $_POST['password'])) {
2015-09-08 02:51:48 +02:00
// Renew the token. This token will be the same inside the session for multiple forms.
$Security->generateTokenCSRF();
Redirect::page('dashboard');
2015-08-18 04:02:19 +02:00
return true;
}
2017-07-16 00:42:37 +02:00
// Bruteforce protection, add IP to the blacklist
$Security->addToBlacklist();
// Create alert
2015-08-18 04:02:19 +02:00
Alert::set($Language->g('Username or password incorrect'));
return false;
}
2015-08-03 02:49:12 +02:00
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
2017-07-16 00:42:37 +02:00
if ($_SERVER['REQUEST_METHOD']=='POST')
2015-03-27 02:00:01 +01:00
{
2017-07-16 00:42:37 +02:00
checkLogin($_POST);
2015-08-03 02:49:12 +02:00
}
// ============================================================================
// Main after POST
// ============================================================================