Commit 4b4395c3 authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

login sas

parent 9c8e4beb
......@@ -2,17 +2,15 @@
class Saas_Service {
public static function fetch($api_key, $software, $object, $method) {
$postdata = http_build_query(
array(
'o' => 'saas_service',
'o' => 'exported_services',
'a' => 'fetch',
'i' => $api_key,
'software' => $software,
'service' => $object."@".$method,
'data' => base64_encode($data)
'service' => $object."@".$method
)
);
......@@ -25,8 +23,7 @@ class Saas_Service {
);
$context = stream_context_create($opts);
return json_decode(file_get_contents($GLOBALS["saas_auth_url"], false, $context));
return json_decode(file_get_contents($GLOBALS["saas_api_url"], false, $context));
}
}
......@@ -64,22 +64,6 @@ class User extends Record {
$user = json_decode($json_user_info);
$_SESSION["logged_user"] = $user;
return $user;
/*
// SQL SELECT users
$sql = "SELECT id, name, email, active, password_digest
FROM users
WHERE name = '".$name."'";
$GLOBALS["data"]->select($sql, $user, "User");
if($user->id != 0 && $user->validate_pw($password, $user->password_digest)) {
$user->roles = Role::fetch_user_roles($user->id);
} else {
$user = new User(0);
// user not found
$user->alert_msg = "Echec de l'authentification";
}
return $user;
*/
}
public function update_password() {
......
......@@ -75,23 +75,19 @@ class AppController {
// application_instance id and key should be in the config file
if(!array_key_exists($GLOBALS["application_instance_id"],
$_SESSION["user"]->roles)) {
//$this->render("no_access"); // TODO
echo "<pre>";
echo "Sorry but is seems that you got no roles for this application instance";
print_r($_SESSION["user"]->roles);
echo "</pre>";
exit();
}
$this->set("roles", $_SESSION["user"]->roles[$GLOBALS["application_instance_id"]]);
$this->set("current_user", $_SESSION["user"]);
$this->render("no_access");
} else {
$this->set("roles", $_SESSION["user"]->roles[$GLOBALS["application_instance_id"]]);
$this->set("current_user", $_SESSION["user"]);
if(!method_exists($this, "_".$_REQUEST["a"])) {
if($this->format == "html") {
$this->render("bad_method");
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
if(!method_exists($this, "_".$_REQUEST["a"])) {
if($this->format == "html") {
$this->render("bad_method");
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
}
exit();
}
exit();
}
}
......
......@@ -7,7 +7,7 @@ class UsersController extends AppController {
function UsersController () {
$this->AppController();
if($GLOBALS["logged_user"]->id == 0) {
if(!array_key_exists("logged_user", $GLOBALS) || $GLOBALS["logged_user"]->id == 0) {
$render = "users/loginform";
} else {
$function_name = "_".$_REQUEST["a"];
......
<?php
function myautoload($class_name) {
if(strpos($class_name, "Controller")) {
include "controllers/". //strtolower(substr($class_name, 0, -10)).".php";
include "controllers/".
(preg_replace( '/(^|[a-z])([A-Z])/e', 'strtolower(strlen("\\1") ? "\\1_\\2" : "\\2")', substr($class_name, 0, -10))).".php";
} else {
if(file_exists("classes/".strtolower($class_name).".php")) {
......@@ -22,4 +22,5 @@ $_REQUEST["o"] = (array_key_exists("o", $_REQUEST)) ? $_REQUEST["o"] : "home";
// call of the controller
$controller = str_replace(' ','',ucwords(str_replace('_',' ',$_REQUEST["o"])))."Controller";
$ctrl = new $controller();
// DEBUG echo "<pre>"; print_r($_SESSION); echo "</pre>";
// DEBUG
echo "<pre>"; print_r($_SESSION); echo "</pre>";
......@@ -12,7 +12,6 @@
<link rel="stylesheet" href="css/bootstrap-switch.min.css">
<link rel="stylesheet" href="css/bootstrap-multiselect.css">
<link rel="stylesheet" href="css/bootstrap-slider.min.css">
<!-- link rel="stylesheet" href="css/datatables.min.css" -->
<link rel="stylesheet" href="css/styles.css">
<script src="js/jquery-2.1.4.min.js"></script>
<title>{% block title %}{% endblock %} - Ludothèque</title>
......@@ -30,6 +29,7 @@
<a class="navbar-brand" href="index.php">
<img id="logo" src="images/ludo-associative.jpg" alt="associative - ludotheque"></a>
</div>
{% if current_user.id %}
<div id="navbar" class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
{% if roles['games'] %}
......@@ -66,7 +66,7 @@
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="index.php?o=users&a=options&i={{ session['logged_user'].id }}"><span class="glyphicon glyphicon-user"></span></a></li>
<li><a href="index.php?o=users&a=options&i={{ current_user.id }}"><span class="glyphicon glyphicon-user"></span></a></li>
<li><a href="index.php?a=logout"><span class="glyphicon glyphicon-log-out"></span></a></li>
</ul>
<form class="navbar-form navbar-right">
......@@ -75,10 +75,11 @@
</div>
</form>
</div>
{% endif %}
</div>
</nav>
<form action="index.php" method="POST" id="defaultform" name="defaultform"
class="form-horizontal" enctype="multipart/form-data">
class="form-horizontal">
<!-- div class="col-sm-9 col-md-10 main" -->
<div class="container">
{% block content %}{% endblock %}
......@@ -92,7 +93,7 @@
<pre>
REQUEST :
{% for key, val in request %}
{% if key != "passwd" %}
{% if key != "password" %}
{{ key }} : {{ val }}
{% endif %}
{% endfor %}
......@@ -102,7 +103,6 @@ REQUEST :
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<!-- script src="js/datatables.js"></script -->
<script src="js/zabuto_calendar.min.js"></script>
<script src="js/typeahead.bundle.min.js"></script>
<script src="js/moment-with-locales.min.js"></script>
......@@ -110,7 +110,7 @@ REQUEST :
<script src="js/bootstrap-switch.min.js"></script>
<script src="js/bootstrap-multiselect.js"></script>
<script src="js/bootstrap-slider.min.js"></script>
{% if session['logged_user'].id %}
{% if current_user.id %}
<script src="js/functions.js"></script>
{% endif %}
</body>
......
......@@ -14,7 +14,7 @@
</div>
<div class="form-group">
<label for="password">Mot de passe</label>
<input type="password" name="passwd" id="passwd" class="form-control"/>
<input type="password" name="password" id="password" class="form-control"/>
</div>
<div class="form-actions">
<button class="btn btn-primary" id="login_button" name="login_button">Se connecter</button>
......@@ -27,7 +27,7 @@ $(document).ready(function () {
alert ("Vous n'avez pas saisi de nom !");
return false;
}
$('#a').val('submit_login');
$('#a').val('login');
document.defaultform.submit();
return true;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment