Commit 0d4f0d8a authored by thibaut-felten's avatar thibaut-felten

Comments

parent 344fc7b0
......@@ -2,19 +2,19 @@
// Config Eden
// define('DB_HOST','localhost');
// define('DB_PORT',3306);
// define('DB_DBNAME','thibaut_felten');
// define('DB_USER','thibaut.felten');
// define('DB_PASSWORD','YpIaegvG');
define('DB_HOST','localhost');
define('DB_PORT',3306);
define('DB_DBNAME','thibaut_felten');
define('DB_USER','thibaut.felten');
define('DB_PASSWORD','YpIaegvG');
//Config local
define('DB_HOST','localhost');
define('DB_PORT',3306);
define('DB_DBNAME','dbtest');
define('DB_USER','root');
define('DB_PASSWORD','root');
// define('DB_HOST','localhost');
// define('DB_PORT',3306);
// define('DB_DBNAME','dbtest');
// define('DB_USER','root');
// define('DB_PASSWORD','root');
define( 'JWT_BACKEND_KEY', '6d8HbcZndVGNAbo4Ih1TGaKcuA1y2BKs-I5CmP' );
define( 'JWT_ISSUER', $_SERVER['HTTP_HOST'] . $_SERVER['CONTEXT_PREFIX']);
\ No newline at end of file
......@@ -44,6 +44,7 @@ class UserController extends Controller {
return Response::errorResponse("unsupported parameters or method in user");
}
// Return one user's data
protected function getUser($id)
{
$user = User::getUserById($id);
......@@ -55,6 +56,7 @@ class UserController extends Controller {
return $response;
}
// Delete a user
protected function deleteUser($id){
$user = User::getUserById($id);
if($user == Array()){
......@@ -66,6 +68,7 @@ class UserController extends Controller {
return $response;
}
// Update the data of a user
protected function updateUser($id,$data){
try {
$jwt_token = $this->request->getJwtToken();
......@@ -119,6 +122,7 @@ class UserController extends Controller {
}
// Create a new user in the database
protected function createUser($data)
{
if(array_key_exists("USER_LOGIN", $data) && array_key_exists("USER_PASSWORD", $data) && array_key_exists("USER_ROLE", $data) && array_key_exists("USER_EMAIL", $data) && array_key_exists("USER_LASTNAME", $data) && array_key_exists("USER_FIRSTNAME", $data)){
......
......@@ -20,6 +20,7 @@ class UsersController extends Controller {
return Response::errorResponse("unsupported parameters or method in users");
}
// Return all user's data
protected function getAllUsers()
{
$users = User::getList();
......
......@@ -12,6 +12,7 @@ class ValidatetokenController extends Controller {
parent::__construct($name, $request);
}
// Check if the user is connected or not
public function processRequest() {
try {
$jwt_token = $this->request->getJwtToken();
......
......@@ -13,32 +13,37 @@ class User extends Model {
return $stm->fetchAll();
}
// load one user from the Db
public static function getUserByID($id) {
$stm = parent::exec('USER_BY_ID',array(':user_id' => $id));
return $stm->fetchAll();
}
// update one user from the Db
public static function updateUser($values) {
$stm = parent::exec('USER_UPDATE',$values);
return "User updated";
}
// Create a new user in the Db
public static function createUser($values) {
$stm = parent::exec('USER_CREATE',$values);
return "User created";
}
// Delete a user from the Db
public static function deleteUser($id) {
$stm = parent::exec('USER_DELETE',array(':id' => $id));
return "User deleted";
}
// Retrieve all users having this login
public static function getListWithLogin($login) {
$stm = parent::exec('USER_GET_WITH_LOGIN',array(':login' => $login));
return $stm->fetchAll();
}
// load the user with the login $login
public static function tryLogin($login)
{
$users = static::getListWithLogin($login);
......
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