Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-cdaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thibaut Felten
projet-cdaw
Commits
0d4f0d8a
Commit
0d4f0d8a
authored
Nov 22, 2020
by
thibaut-felten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments
parent
344fc7b0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
11 deletions
+22
-11
config.php
backend/MVC/config/config.php
+10
-10
UserController.class.php
backend/MVC/controller/UserController.class.php
+4
-0
UsersController.class.php
backend/MVC/controller/UsersController.class.php
+1
-0
ValidatetokenController.class.php
backend/MVC/controller/ValidatetokenController.class.php
+1
-0
User.class.php
backend/MVC/model/User.class.php
+6
-1
No files found.
backend/MVC/config/config.php
View file @
0d4f0d8a
...
...
@@ -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
backend/MVC/controller/UserController.class.php
View file @
0d4f0d8a
...
...
@@ -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
)){
...
...
backend/MVC/controller/UsersController.class.php
View file @
0d4f0d8a
...
...
@@ -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
();
...
...
backend/MVC/controller/ValidatetokenController.class.php
View file @
0d4f0d8a
...
...
@@ -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
();
...
...
backend/MVC/model/User.class.php
View file @
0d4f0d8a
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment