<?php
// required headers
header("Access-Control-Allow-Origin: *");
//header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

include_once 'api/config/database.php';
include_once 'api/objects/user.php';

$database = new Database();
$db = $database->getConnection();
$userid = "";
$existing_user = "false";
$userrole = "";
$accounting_view = "";
$city = "";
$code = "";
$profilepicture = "";

$user = new User($db);
$user->username = $_POST["username"];
$user->password = $_POST["password"];

if($user->exist()){
	$existing_user = "true";
	$userid = $user->id;
	$userrole = $user->userrole;
	$accounting_view =$user->accounting_view;
	$city = $user->city;
	$code = $user->code;
	$profilepicture = $user->profilepicture;
}
?>