Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
LoginPage | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
execute | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\Pages; |
4 | |
5 | use MediaWiki\SpecialPage\SpecialPage; |
6 | |
7 | /** |
8 | * A simple SecurePoll subpage which handles guest logins from a remote website, |
9 | * starts a session, and then redirects to the voting page. |
10 | */ |
11 | class LoginPage extends ActionPage { |
12 | /** @inheritDoc */ |
13 | public function execute( $params ) { |
14 | $out = $this->specialPage->getOutput(); |
15 | |
16 | if ( !count( $params ) ) { |
17 | $out->addWikiMsg( 'securepoll-too-few-params' ); |
18 | |
19 | return; |
20 | } |
21 | |
22 | $electionId = intval( $params[0] ); |
23 | $this->election = $this->context->getElection( $electionId ); |
24 | if ( !$this->election ) { |
25 | $out->addWikiMsg( 'securepoll-invalid-election', $electionId ); |
26 | |
27 | return; |
28 | } |
29 | |
30 | $auth = $this->election->getAuth(); |
31 | $status = $auth->newRequestedSession( $this->election ); |
32 | if ( !$status->isOK() ) { |
33 | $out->addWikiTextAsInterface( $status->getWikiText() ); |
34 | return; |
35 | } |
36 | $votePage = SpecialPage::getTitleFor( 'SecurePoll', 'vote/' . $this->election->getId() ); |
37 | $out->redirect( $votePage->getFullURL() ); |
38 | } |
39 | } |