Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
voting.typo3.org
extensions
election
Commits
b6345dbd
Commit
b6345dbd
authored
Dec 23, 2015
by
Oliver Eglseder
Browse files
[TASK] Add fallback fo failed FE requests
parent
1b6e054e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/FeDashboardController.php
0 → 100644
View file @
b6345dbd
<?php
namespace
TYPO3\Election\Controller
;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use
TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
/**
* Class FeDashboardController
*/
class
FeDashboardController
extends
ActionController
{
const
CONTROLLER_NAME
=
'FeDashboard'
;
const
ACTION_INDEX
=
'index'
;
/**
* @var \TYPO3\Election\Domain\Repository\ElectionRepository
* @inject
*/
protected
$electionRepository
=
null
;
/**
*
*/
public
function
indexAction
()
{
$this
->
view
->
assign
(
'elections'
,
$this
->
electionRepository
->
findAll
());
}
/**
* @return string
*/
public
static
function
getActionsForPluginConfiguration
()
{
return
implode
(
','
,
[
self
::
ACTION_INDEX
]);
}
}
Classes/Controller/FeElectionController.php
View file @
b6345dbd
...
...
@@ -14,7 +14,9 @@ namespace TYPO3\Election\Controller;
* The TYPO3 project - inspiring people to share!
*/
use
TYPO3\CMS\Core\Messaging\AbstractMessage
;
use
TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
use
TYPO3\CMS\Extbase\Utility\LocalizationUtility
;
use
TYPO3\Election\Domain\Model\ElectionInvitation
;
/**
...
...
@@ -47,14 +49,6 @@ class FeElectionController extends ActionController
}
}
/**
*
*/
public
function
voidAction
()
{
return
''
;
}
/**
* @param ElectionInvitation $electionInvitation
* @param string $hmac
...
...
@@ -62,13 +56,26 @@ class FeElectionController extends ActionController
*/
public
function
voteAction
(
ElectionInvitation
$electionInvitation
=
null
,
$hmac
=
''
)
{
$saltedEmail
=
$electionInvitation
->
getSecret
()
.
$electionInvitation
->
getElector
()
->
getEmail
();
if
(
$this
->
hashService
->
validateHmac
(
$saltedEmail
,
$hmac
))
{
\
TYPO3\CMS\Extbase\Utility\DebuggerUtility
::
var_dump
(
'hmac valid'
,
__CLASS__
.
'@'
.
__LINE__
,
20
);
if
(
null
!==
$electionInvitation
&&
''
!==
$hmac
)
{
$saltedEmail
=
$electionInvitation
->
getSecret
()
.
$electionInvitation
->
getElector
()
->
getEmail
();
if
(
$this
->
hashService
->
validateHmac
(
$saltedEmail
,
$hmac
))
{
$this
->
view
->
assign
(
'electionInvitation'
,
$electionInvitation
);
}
else
{
$this
->
addFlashMessage
(
LocalizationUtility
::
translate
(
'controller.fe.election.vote.hmac_invalid'
,
'election'
),
LocalizationUtility
::
translate
(
'controller.fe.election.vote.request_failed'
,
'election'
),
AbstractMessage
::
ERROR
);
$this
->
redirect
(
FeDashboardController
::
ACTION_INDEX
,
FeDashboardController
::
CONTROLLER_NAME
);
}
}
else
{
\
TYPO3\CMS\Extbase\Utility\DebuggerUtility
::
var_dump
(
'hmac invalid'
,
__CLASS__
.
'@'
.
__LINE__
,
20
);
$this
->
addFlashMessage
(
LocalizationUtility
::
translate
(
'controller.fe.election.vote.no_election_or_hmac'
,
'election'
),
LocalizationUtility
::
translate
(
'controller.fe.election.vote.request_failed'
,
'election'
),
AbstractMessage
::
ERROR
);
$this
->
redirect
(
FeDashboardController
::
ACTION_INDEX
,
FeDashboardController
::
CONTROLLER_NAME
);
}
die
;
}
/**
...
...
@@ -78,4 +85,12 @@ class FeElectionController extends ActionController
{
return
implode
(
','
,
[
self
::
ACTION_VOTE
]);
}
/**
*
*/
public
function
voidAction
()
{
return
''
;
}
}
Resources/Private/Language/locallang.xlf
View file @
b6345dbd
...
...
@@ -385,6 +385,18 @@
<source>
Election
</source>
</trans-unit>
<!-- FE ELECTION -->
<trans-unit
id=
"controller.fe.election.vote.hmac_invalid"
>
<source>
HMAC invalid. You are not allowed to request this page.
</source>
</trans-unit>
<trans-unit
id=
"controller.fe.election.vote.request_failed"
>
<source>
Request failed.
</source>
</trans-unit>
<trans-unit
id=
"controller.fe.election.vote.no_election_or_hmac"
>
<source>
The link you clicked is not valid anymore.
</source>
</trans-unit>
</body>
</file>
</xliff>
Resources/Private/Layouts/Frontend.html
0 → 100644
View file @
b6345dbd
<f:flashMessages/>
<f:render
section=
"Main"
/>
Resources/Private/Partials/Model/Nominee/VoteList.html
0 → 100644
View file @
b6345dbd
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<table
class=
"table"
>
<thead>
<tr>
<th>
<f:translate
key=
"model.nominee.field.image"
>
Image
</f:translate>
</th>
<th>
<f:translate
key=
"model.abstract_person.field.full_name"
>
Name
</f:translate>
</th>
<th>
<f:translate
key=
"model.abstract_person.field.email"
>
Email
</f:translate>
</th>
<th>
<f:translate
key=
"view.be.anything.options"
>
Vote
</f:translate>
</th>
</tr>
</thead>
<tbody>
<f:for
each=
"{nominees}"
as=
"nominee"
>
<tr>
<td>
<f:image
image=
"{nominee.image}"
width=
"50c"
height=
"50c"
/>
</td>
<td>
<f:link.action
action=
"edit"
controller=
"BeNominee"
arguments=
"{nominee:nominee}"
>
{nominee.fullName}
</f:link.action>
</td>
<td>
{nominee.email}
</td>
<td>
<div
class=
"btn-group"
>
<f:link.action
class=
"btn btn-default"
action=
"edit"
controller=
"BeNominee"
arguments=
"{nominee:nominee}"
>
<core:icon
identifier=
"actions-edit-rename"
/>
</f:link.action>
</div>
</td>
</tr>
</f:for>
</tbody>
</table>
Resources/Private/Templates/FeDashboard/Index.html
0 → 100644
View file @
b6345dbd
<f:layout
name=
"Frontend"
/>
<f:section
name=
"Main"
>
<h1>
Elections
</h1>
<table>
<thead>
<tr>
<th>
Title
</th>
</tr>
</thead>
<tbody>
<f:for
each=
"{elections}"
as=
"election"
>
<tr>
<td>
{election.title}
</td>
</tr>
</f:for>
</tbody>
</table>
</f:section>
Resources/Private/Templates/FeElection/Vote.html
0 → 100644
View file @
b6345dbd
<f:layout
name=
"Frontend"
/>
<f:section
name=
"Main"
>
<f:debug>
{_all}
</f:debug>
<h2>
Election: {electionInvitation.electionCircular.election.title}
</h2>
<h3>
Nominees
</h3>
<f:render
partial=
"Model/Nominee/VoteList"
arguments=
"{nominees:electionInvitation.electionCircular.election.nominees}"
/>
</f:section>
ext_localconf.php
View file @
b6345dbd
...
...
@@ -12,10 +12,14 @@ if (!defined('TYPO3_MODE')) {
'TYPO3.election'
,
'pi1'
,
array
(
\
TYPO3\Election\Controller\FeDashboardController
::
CONTROLLER_NAME
=>
\
TYPO3\Election\Controller\FeDashboardController
::
getActionsForPluginConfiguration
(),
\
TYPO3\Election\Controller\FeElectionController
::
CONTROLLER_NAME
=>
\
TYPO3\Election\Controller\FeElectionController
::
getActionsForPluginConfiguration
(),
),
array
(
\
TYPO3\Election\Controller\FeDashboardController
::
CONTROLLER_NAME
=>
\
TYPO3\Election\Controller\FeDashboardController
::
getActionsForPluginConfiguration
(),
\
TYPO3\Election\Controller\FeElectionController
::
CONTROLLER_NAME
=>
\
TYPO3\Election\Controller\FeElectionController
::
getActionsForPluginConfiguration
(),
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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