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
1
Issues
1
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
Quentin Vrel
projet-cdaw
Commits
498836f3
Commit
498836f3
authored
Dec 02, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added checks
parent
3b680c7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
UserController.class.php
BackEnd/src/controller/UserController.class.php
+24
-0
No files found.
BackEnd/src/controller/UserController.class.php
View file @
498836f3
...
...
@@ -104,6 +104,30 @@ class UserController extends Controller
*/
protected
function
addUser
(
$array
)
{
// Check if mendatory fields are filed
if
(
!
isset
(
$array
[
'login'
])
||
!
isset
(
$array
[
'pwd'
])
||
!
isset
(
$array
[
'mail'
]))
{
$message
=
json_encode
([
"message"
=>
'login, pwd and mail fields are mandatory'
]);
return
new
Response
(
422
,
$message
);
}
// Check if mail is valid
if
(
!
filter_var
(
$array
[
'mail'
],
FILTER_VALIDATE_EMAIL
))
{
$message
=
json_encode
([
"message"
=>
'Email is not valid'
]);
return
new
Response
(
422
,
$message
);
}
// Fill facultative field
if
(
!
isset
(
$array
[
'avatar'
])){
$array
[
'avatar'
]
=
'default.png'
;
}
if
(
!
isset
(
$array
[
'lastname'
])){
$array
[
'lastname'
]
=
''
;
}
if
(
!
isset
(
$array
[
'firstname'
])){
$array
[
'firstname'
]
=
''
;
}
// Create row
User
::
addRow
(
$array
);
$message
=
json_encode
([
"message"
=>
'User succesfully added!'
]);
$response
=
Response
::
createdResponse
(
$message
);
...
...
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