public function testLoginSuccess3() { $this->testRegisterSuccess(); $response = UserManager::login('*****@*****.**', 'asdf'); $this->assertTrue(isset($response['redirect'])); $this->assertEquals("/index.php", $response['redirect']); }
function onPost($postData, FormSubmit $sender) { $userManager = new UserManager(); if ($sender != $this->submitButton) { throw new Exception("The post sender is invalid!"); } $userManager->login($this->usernameBox->text, $this->passwordBox->text); }
static function showLoginForm($error = null) { if ($error == null && count($_POST) > 0) { if (isset($_POST["username"])) { $data["username"] = $_POST["username"]; } else { $error[] = "non c'è lo username"; } if (isset($_POST["password"])) { $data["password"] = $_POST["password"]; } else { $error[] = "password non presente"; } if (count($error) > 0) { $s = FileManager::appendToRootPath("error?e=" . $error[0]); } else { $dataFiltered = Filter::filterArray($data); if (($logged = UserManager::login($data)) === true) { $s = FileManager::appendToRootPath(""); } else { require_once 'errors/errors.php'; $s = FileManager::appendToRootPath("error?e=" . $logged); } } if (!headers_sent()) { header("location: " . $s); } else { ?> <script type="text/javascript"> location.href = "<?php echo $s; ?> "; </script> <?php } } ?> <form name="login" action="<?php echo FileManager::appendToRootPath("Login"); ?> " method="post"> <?php //<!-- show error messages --> if ($error != null) { foreach ($error as $valore) { echo $valore . "<br/>"; } } ?> <p><input type="text" name="username" value="" /></p> <p><input type="password" name="password" value="" /></p> <p><input class="button" type="submit" value="Accedi"></form></p> <?php }
public function route($params) { $userManager = new UserManager(); if ($userManager->returnUser()) { $this->redirect('dashboard'); } $header_menu = "login_bar_none"; $this->header_menu = $header_menu; // Hlavička stránky $this->head['title_html'] = 'Přihlášení do konferečního systému'; if ($_POST) { try { $userManager->login($_POST['jmeno'], $_POST['heslo']); $this->redirect('dashboard'); } catch (Exception $chyba) { $this->addMessage("Špatně zadané údaje"); } } // Nastavení šablony $this->view = 'login'; }
//we give the session a unique csrf token so malicious links on other sites cannot take advantage of users if (!isset($_SESSION['csrftoken'])) { $_SESSION['csrftoken'] = mt_rand(); } if (isset($_SESSION['loggedin'])) { $response = ["redirect" => "/index.php"]; } else { if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['csrftoken'])) { $username = $_POST['username']; $password = $_POST['password']; $csrftoken = $_POST['csrftoken']; if ($csrftoken != $_SESSION['csrftoken']) { $response = ["message" => "Cross Site Request Forgery Detected!"]; } else { require_once realpath(dirname(__DIR__) . "/class/UserManager.php"); if (isset($_POST['redirect'])) { $redirect = $_POST['redirect']; $response = UserManager::login($username, $password, $redirect); } else { $response = UserManager::login($username, $password); } } } else { if (isset($_POST['justregistered']) && $_POST['justregistered'] == 1) { $response = ["message" => "Thank you for registering! Please log in to continue."]; } else { $response = ["message" => "Form incomplete."]; } } } return $response;
<?php session_start(); header('Content-Type: text/html; charset=utf-8'); require_once 'config.inc.php'; /** LOGOUT */ if (isset($_POST['logout'])) { UserManager::logout(); } /** LOGIN */ if (isset($_POST['uname'])) { UserManager::login($_POST['uname'], $_POST['pass']); } ?> <!DOCTYPE html> <html lang="en"> <head> <title><?php echo TITLE; ?> - Translation Tool</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link href="./images/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <link href="./images/favicon.ico" rel="apple-touch-icon" /> <link rel="stylesheet" href="../../assets/libs/bootstrap/dist/css/bootstrap.min.css" type="text/css" /> <link rel="stylesheet" href="../../assets/css/bootstrap.custom.css" type="text/css" /> <link rel="stylesheet" href="./css/bootstrap.custom.css" type="text/css" /> <script type="text/javascript" src="../../assets/libs/jquery/dist/jquery.min.js"></script>
<?php if (session_status() == PHP_SESSION_NONE) { session_start(); } require 'scripts/init.php'; loadScripts(); $um = new UserManager(); $data = $um->login($_POST["username"], md5($_POST["password"])); if ($data['userid'] != null) { $_SESSION['userid'] = $data['userid']; } echo json_encode($data, JSON_FORCE_OBJECT);
<?php date_default_timezone_set('America/New_York'); $action = isset($_POST['action']) ? $_POST['action'] : ''; if ($action == 'login') { require_once __DIR__ . '/../oop/manager/UserManager.php'; $ID = $_POST['userID']; $PIN = $_POST['PIN']; $userManager = new UserManager(); $user = $userManager->login($ID, $PIN); // If we have correctly logged in if ($user != null) { if ($user instanceof Supervisor) { echo '<script>location="listTutors.php";</script>'; } else { echo '<script>location="updateSchedule.php";</script>'; } exit; } else { echo '<script>alert("The user or the password are incorrect");</script>'; } } include 'header.php'; ?> <script> function isUserValid() { if (!/^[0-9]+$/.test($('#userID').val())) { showError('error-userID'); return false;