-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b56ca0
commit 3c34650
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Controllers\User; | ||
|
||
use \BNETDocs\Models\User\Activate as UserActivateModel; | ||
use \CarlBennett\MVC\Libraries\Common; | ||
use \CarlBennett\MVC\Libraries\Controller; | ||
use \CarlBennett\MVC\Libraries\Router; | ||
use \CarlBennett\MVC\Libraries\View; | ||
|
||
class Activate extends Controller { | ||
|
||
public function &run( Router &$router, View &$view, array &$args ) { | ||
|
||
$model = new UserActivateModel(); | ||
|
||
$data = $router->getRequestQueryArray(); | ||
|
||
$model->token = isset( $data[ 't' ] ) ? $data[ 't' ] : null; | ||
$model->error = 'INVALID_TOKEN'; | ||
|
||
$view->render( $model ); | ||
|
||
$model->_responseCode = 200; | ||
$model->_responseHeaders[ 'Content-Type' ] = $view->getMimeType(); | ||
$model->_responseTTL = 0; | ||
|
||
return $model; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Models\User; | ||
|
||
use \CarlBennett\MVC\Libraries\Model; | ||
|
||
class Activate extends Model { | ||
|
||
public $token; | ||
public $error; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Templates\User; | ||
|
||
use \CarlBennett\MVC\Libraries\Common; | ||
use \CarlBennett\MVC\Libraries\Pair; | ||
|
||
$title = 'Activate Account'; | ||
$description = 'This form allows an individual to activate their account with a token.'; | ||
$this->opengraph->attach( new Pair( 'url', '/user/activate' )); | ||
|
||
switch ( $this->getContext()->error ) { | ||
case 'INVALID_TOKEN': | ||
$message = 'The token is expired or invalid and therefore cannot be used.'; | ||
break; | ||
default: | ||
$message = $this->getContext()->error; | ||
} | ||
|
||
$this->additional_css[] = '/a/forms.css'; | ||
require('./header.inc.phtml'); | ||
?> | ||
<article> | ||
<?php if ($this->getContext()->error !== false) { ?> | ||
<header>Activate Account</header> | ||
<?php if (!empty($message)) { ?> | ||
<section class="red"> | ||
<p><?php echo $message; ?></p> | ||
</section> | ||
<?php } ?> | ||
<form method="GET" action="?"> | ||
<section> | ||
<label for="t">Token:</label><br/> | ||
<input | ||
type="text" | ||
name="t" | ||
id="token" | ||
value="<?php echo filter_var($this->getContext()->token, FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?>" | ||
tabindex="1" | ||
required | ||
autofocus="autofocus" | ||
/> | ||
</section> | ||
<section> | ||
<input | ||
type="submit" | ||
value="Activate Account" | ||
tabindex="2" | ||
/> | ||
</section> | ||
</form> | ||
<?php } else { ?> | ||
<header class="green">Account Activated</header> | ||
<section class="green"> | ||
<p>Your account has been activated successfully!</p> | ||
<p>Use the navigation to the left to move to another page.</p> | ||
</section> | ||
<?php } ?> | ||
</article> | ||
<?php require('./footer.inc.phtml'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace BNETDocs\Views\User; | ||
|
||
use \BNETDocs\Models\User\Activate as UserActivateModel; | ||
|
||
use \CarlBennett\MVC\Libraries\Exceptions\IncorrectModelException; | ||
use \CarlBennett\MVC\Libraries\Model; | ||
use \CarlBennett\MVC\Libraries\Template; | ||
use \CarlBennett\MVC\Libraries\View; | ||
|
||
class ActivateHtml extends View { | ||
|
||
public function getMimeType() { | ||
return 'text/html;charset=utf-8'; | ||
} | ||
|
||
public function render( Model &$model ) { | ||
if (!$model instanceof UserActivateModel) { | ||
throw new IncorrectModelException(); | ||
} | ||
(new Template( $model, 'User/Activate' ))->render(); | ||
} | ||
|
||
} |