Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
don
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
25
Issues
25
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
LQDN Adminsys
don
Commits
cd2461a7
Verified
Commit
cd2461a7
authored
Oct 14, 2019
by
Guinness
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix potential security issue by validating the email structure
parent
d810f602
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
app/controller/campaign.php
app/controller/campaign.php
+8
-2
src/LQDN/Exception/InvalidEmailException.php
src/LQDN/Exception/InvalidEmailException.php
+7
-0
src/LQDN/Handler/UserHandler.php
src/LQDN/Handler/UserHandler.php
+10
-0
No files found.
app/controller/campaign.php
View file @
cd2461a7
...
...
@@ -4,6 +4,7 @@ namespace Controller;
use
LQDN\Command\UserUpdateTotalCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\DonationCreateCommand
;
use
LQDN\Exception\InvalidEmailException
;
class
Campaign
extends
Controller
{
...
...
@@ -122,8 +123,13 @@ class Campaign extends Controller
$cumul_id
=
$user
[
'cumul'
];
}
else
{
// The user does not exist, so let's create it
$result
=
$db
->
query
(
"INSERT INTO users (pseudo, email, hash)
VALUES ('"
.
$f3
->
get
(
'pseudo'
)
.
"', '
$email
', '
$hash
')"
);
try
{
$f3
->
get
(
'container'
)[
'command_handler'
]
->
handle
(
new
UserCreateCommand
(
$email
,
$hash
,
$f3
->
get
(
'pseudo'
),
0
,
0
));
}
catch
(
InvalidEmailException
$e
)
{
$f3
->
set
(
"error"
,
_
(
"Email Invalide"
));
$f3
->
error
(
"403"
);
}
$user_id
=
$db
->
lastInsertId
();
}
}
...
...
src/LQDN/Exception/InvalidEmailException.php
0 → 100644
View file @
cd2461a7
<?php
namespace
LQDN\Exception
;
class
InvalidEmailException
extends
\
RuntimeException
{
}
src/LQDN/Handler/UserHandler.php
View file @
cd2461a7
...
...
@@ -8,6 +8,14 @@ use LQDN\Command\UserUpdateTotalCommand;
use
LQDN\Command\UserUpdateCumulCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\AdminUpdateTotalUsersCommand
;
use
LQDN\Exception\InvalidEmailException
;
function
checkEmail
(
$email
)
{
if
(
!
filter_var
(
$email
,
FILTER_VALIDATE_EMAIL
))
{
throw
new
InvalidEmailException
();
}
}
class
UserHandler
{
...
...
@@ -25,6 +33,7 @@ class UserHandler
*/
public
function
handleUserUpdateByAdminCommand
(
UserUpdateByAdminCommand
$command
)
{
checkEmail
(
$command
->
getEmail
());
$this
->
connection
->
executeUpdate
(
'UPDATE users SET pseudo = :username, email = :email, commentaire = :comment, cumul = :cumul, total = :total WHERE id = :id'
,
[
'username'
=>
$command
->
getUsername
(),
'email'
=>
$command
->
getEmail
(),
...
...
@@ -42,6 +51,7 @@ class UserHandler
*/
public
function
handleUserCreateCommand
(
UserCreateCommand
$command
)
{
checkEmail
(
$command
->
getEmail
());
$this
->
connection
->
executeUpdate
(
'INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)'
,
[
'email'
=>
$command
->
getEmail
(),
'hash'
=>
$command
->
getHash
(),
...
...
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