SnipeITAPI/login.php

27 lines
517 B
PHP
Raw Normal View History

2016-05-16 15:43:49 -06:00
<?php
2016-05-19 00:41:51 -06:00
/**
* Handles login requests, authentication, and session creation.
*/
2016-05-16 15:43:49 -06:00
require 'required.php';
2016-05-19 00:41:51 -06:00
// For lazy browser testing
2016-05-16 15:43:49 -06:00
//$_POST = $_GET;
$user = $_POST['user'];
$pass = $_POST['pass'];
if (is_empty($user)) {
2016-05-19 00:28:50 -06:00
sendError("Missing username.");
2016-05-16 15:43:49 -06:00
}
if (is_empty($pass)) {
sendError("Missing password.");
}
if (authenticate_user($user, $pass)) {
$_SESSION['user'] = $user;
$_SESSION['loggedin'] = true;
sendOK("Login successful.");
} else {
sendError("Login incorrect, try again.");
}