base_leaf_app/index.php
<?php
require __DIR__ . '/vendor/autoload.php';
require("utils.php");
db()->connect([
'dbtype' => 'sqlite',
'dbname' => './db/qca.sqlite',
]);
app()->csrf();
auth()->config('session', true);
auth()->config('token.lifetime', 0);
app()->get('/', function () {
checkAuth();
header("Location: /qca");
});
app()->get('/qca', function () {
checkAuth();
response()->render('home');
});
app()->get('/qca/login', function () {
response()->render('login');
});
app()->post('/qca/login',function(){
$user = request()->get('username');
$password = request()->get('password');
$success = auth()->login([
'username' => $user,
'password' => $password
]);
if ($success) {
header('Location: /qca/');
} else {
//$error = auth()->errors();
header('Location: /qca/login');
}
});
app()->get('/qca/logout', function () {
auth()->logout('/qca/login');
});
app()->run();