Exemplo n.º 1
0
<?php

require_once '../../Public/php/authentication.php';
require_once '../../Public/php/utils.php';
echo "Trying a login...\n";
# Works here with my uname as gmail and pw as golike with no bd and no caps
validateAndCreateSession("", "");
# Of course, cookie think is bit tricky, doesn't quite work on cmdline
Exemplo n.º 2
0
require_once 'php/commuteLogger.php';
require_once 'php/utils.php';
$app = new \Slim\App();
// Route for getting an html template for use in a view
$app->get('/tpl/{name}', function ($request, $response, $args) {
    $templateName = $request->getAttribute('name');
    $htdoc = new DOMDocument();
    $htdoc->validateOnParse = true;
    // Special view-specific handling... loads some template from file
    handleTemplateSpecifics($request, $response, $args, $templateName, $htdoc);
    // Return document to client
    echo $htdoc->saveHTML();
});
// Route for attempting to log in
$app->post('/login', function () {
    validateAndCreateSession($_POST['username'], $_POST['password']);
});
// Route for logging out
$app->get('/logout', function () {
    endLogInSession();
});
// Middleware function to return empty error response if not logged in
$RequireAuthMW = function ($request, $response, $next) {
    if (!hasValidSession()) {
        $rsp = new JsonResponse_Basic("Authentication required for route.");
        $rsp->respondAndExit();
    }
    $response = $next($request, $response);
    return $response;
};
// Route for starting a trip