Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
potage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
potage
Commits
e7414e79
Commit
e7414e79
authored
Aug 31, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token auth: factorisation, debug, et adapte l'envoi via la commande
parent
34869394
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
20 deletions
+33
-20
src/PotageBundle/Command/SendMailCommand.php
src/PotageBundle/Command/SendMailCommand.php
+19
-14
src/PotageBundle/Controller/DefaultController.php
src/PotageBundle/Controller/DefaultController.php
+10
-2
src/PotageBundle/Security/TokenAuthenticator.php
src/PotageBundle/Security/TokenAuthenticator.php
+3
-3
src/PotageBundle/Services/LettreToken.php
src/PotageBundle/Services/LettreToken.php
+1
-1
No files found.
src/PotageBundle/Command/SendMailCommand.php
View file @
e7414e79
...
...
@@ -4,6 +4,7 @@ namespace PotageBundle\Command;
use
PotageBundle\Entity\Groupe
;
use
PotageBundle\Entity\Lettre
;
use
PotageBundle\Services\LettreToken
;
use
PotageBundle\Services\Newsletter
;
use
Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
use
Symfony\Component\Console\Input\InputInterface
;
...
...
@@ -11,31 +12,35 @@ use Symfony\Component\Console\Output\OutputInterface;
class
SendMailCommand
extends
ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected
function
configure
()
{
$this
->
setName
(
'potage:mail:send'
)
->
setDescription
(
"Test d'envoi d'une infolettre!"
);
}
public
$newsletter
;
private
$newsletter
;
private
$lettreToken
;
/**
* SendMailCommand constructor.
*
* @param Newsletter $newsletter
* @param LettreToken $lettreToken
*/
public
function
__construct
(
Newsletter
$newsletter
)
public
function
__construct
(
Newsletter
$newsletter
,
LettreToken
$lettreToken
)
{
parent
::
__construct
();
$this
->
newsletter
=
$newsletter
;
$this
->
lettreToken
=
$lettreToken
;
}
/**
* {@inheritdoc}
*/
protected
function
configure
()
{
$this
->
setName
(
'potage:mail:send'
)
->
setDescription
(
"Test d'envoi d'une infolettre!"
);
}
/**
* @param InputInterface $input
* @param OutputInterface $output
...
...
@@ -54,7 +59,7 @@ class SendMailCommand extends ContainerAwareCommand
->
getRepository
(
'PotageBundle:Lettre'
)
->
findOneForSend
(
7
);
$retour
=
$this
->
newsletter
->
sendLettreToGroup
(
$lettre
);
$retour
=
$this
->
newsletter
->
sendLettreToGroup
(
$lettre
,
$this
->
lettreToken
);
for
(
$i
=
0
;
$i
<
count
(
$retour
);
$i
++
)
{
$output
->
writeln
(
$i
.
' | '
.
$retour
[
$i
][
'to'
]
.
' | '
.
$retour
[
$i
][
'result'
]);
...
...
src/PotageBundle/Controller/DefaultController.php
View file @
e7414e79
...
...
@@ -110,10 +110,18 @@ class DefaultController extends MasterController
}
}
/**
* pour debug
*/
$tokenEncoded
=
$request
->
query
->
get
(
'token'
);
$tokenDecoded
=
$lettreToken
->
decodePotageAccess
(
$tokenEncoded
);
return
$this
->
render
(
'@Potage/Default/today.html.twig'
,
array
(
'user'
=>
$user
,
'groupes'
=>
$groupes
'groupes'
=>
$groupes
,
'tokenEncoded'
=>
$tokenEncoded
,
'tokenDecoded'
=>
$tokenDecoded
,
));
}
...
...
src/PotageBundle/Security/TokenAuthenticator.php
View file @
e7414e79
...
...
@@ -96,10 +96,10 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
public
function
getCredentials
(
Request
$request
)
{
$tokenEncoded
=
$request
->
query
->
get
(
'token'
);
$
inToken
=
$this
->
lettreToken
->
decodePotageAccess
(
$tokenEncoded
);
$
tokenDecoded
=
$this
->
lettreToken
->
decodePotageAccess
(
$tokenEncoded
);
return
array
(
'token
'
=>
$inToken
[
'user_token
'
],
'token
_key'
=>
$tokenDecoded
[
'token_key
'
],
);
}
...
...
@@ -120,7 +120,7 @@ class TokenAuthenticator extends AbstractGuardAuthenticator
*/
public
function
getUser
(
$credentials
,
UserProviderInterface
$userProvider
)
{
$tokenKey
=
$credentials
[
'token'
];
$tokenKey
=
$credentials
[
'token
_key
'
];
if
(
null
===
$tokenKey
)
{
return
null
;
...
...
src/PotageBundle/Services/LettreToken.php
View file @
e7414e79
...
...
@@ -82,7 +82,7 @@ class LettreToken
return
array
(
'user_id'
=>
$data
[
0
],
'
user_token
'
=>
$data
[
1
],
'
token_key
'
=>
$data
[
1
],
'lettre_id'
=>
$data
[
2
],
'lettre_ref'
=>
$data
[
3
],
);
...
...
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