Exemplo n.º 1
0
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
session_start();
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login');
        }
    };
};
$app->post("/auth/process/admin", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    $email = $array['email'];
    $password = $array['password'];
    $person = $db->admin()->where('email', $email)->where('password', $password);
    $count = count($person);
    if ($count == 1) {
        $_SESSION['admin'] = $email;
        $data = array('login_success' => "true", 'login_attempt_by' => $email, 'message' => "Successfull sigin");
    } else {
        $data = array('login_success' => "false", 'login_attempt_by' => $email, 'message' => "please provide correct details");
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
$app->get('/auth/process/admin', function () use($app) {
    if (isset($_SESSION['admin'])) {
        $data = $_SESSION['admin'];
    } else {
        $data = false;
Exemplo n.º 2
0
        }
    };
};
$authenticate_admin = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['admin'])) {
            $app->redirect('/shiningfloor/admin-shiningfloor/#/access/signin');
        }
    };
};
session_start();
$app->post("/auth/process/admin", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    $email = $array['email'];
    $password = md5(sha1($array['password']));
    $person = $db->admin()->where('email', $email)->where('password', $password);
    $count = count($person);
    //    print_r ($array);
    if ($count == 1) {
        $_SESSION['admin'] = $email;
        $data = array('login_success' => "true", 'login_attempt_by' => $email, 'message' => "Successfull sigin");
    } else {
        $data = array('login_success' => "false", 'login_attempt_by' => $email, 'message' => "please provide correct details");
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
$app->post("/auth/signup/admin", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    // $name    = $array['name'];
    $email = $array['email'];