function getSessionUserSection()
{
    $sessionUser = new databaseManager();
    $usergroup = array();
    $user = JFactory::getUser();
    foreach ($user->groups as $key => $value) {
        $a = $key;
        $usergroup[] = $sessionUser->retrieveUserGroup($a);
    }
    return $usergroup[1];
}
Exemple #2
0
<?php

require "../libs/Slim/Slim.php";
require_once 'usermanager.php';
require_once 'dbmanager.php';
require_once 'MeasureService.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$dbManager = new databaseManager();
$usermanager = new userManager($dbManager);
$measureService = new MeasureService($dbManager);
$app->response->headers->set('Content-Type', 'application/json');
$app->get('/notify', function () use($app, $dbManager, $usermanager) {
});
$app->get('/auth/:token', function ($token) use($app, $dbManager, $usermanager) {
    if ($token != null && $token != "") {
        if ($usermanager->validateToken($token)) {
            $app->response->setStatus(202);
            return;
        }
    }
    $app->response->setStatus(403);
});
$app->post('/auth', function () use($app, $dbManager, $usermanager) {
    $body = $app->request->getBody();
    $request = json_decode($body, true);
    if (array_key_exists("username", $request) && array_key_exists("password", $request)) {
        $username = $request['username'];
        $password = $request['password'];
        if ($username != null && $password != null && $password !== "" && $username !== "") {
            if ($usermanager->validateCredentials($username, $password)) {