Skip to content

Commit 638d798

Browse files
committed
Next pass at bootstrap conversion
1 parent 9b60d79 commit 638d798

File tree

2 files changed

+43
-76
lines changed

2 files changed

+43
-76
lines changed
+6-22
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,30 @@
11
<?php
2-
32
namespace BNETDocs\Controllers\User;
43

54
use \BNETDocs\Libraries\User;
65
use \BNETDocs\Models\User\CreatePassword as UserCreatePasswordModel;
7-
86
use \CarlBennett\MVC\Libraries\Common;
97
use \CarlBennett\MVC\Libraries\Controller;
108
use \CarlBennett\MVC\Libraries\Router;
119
use \CarlBennett\MVC\Libraries\View;
1210

13-
class CreatePassword extends Controller {
14-
public function &run(Router &$router, View &$view, array &$args) {
11+
class CreatePassword extends Controller
12+
{
13+
public function &run(Router &$router, View &$view, array &$args)
14+
{
1515
$model = new UserCreatePasswordModel();
16-
1716
$data = $router->getRequestBodyArray();
1817

1918
$model->input = (
2019
isset($data['input']) ? $data['input'] : null
2120
);
21+
2222
$model->output = (
23-
!is_null($model->input) ? self::transform($model->input) : null
23+
!is_null($model->input) ? User::createPassword($model->input) : null
2424
);
2525

2626
$view->render($model);
2727
$model->_responseCode = 200;
2828
return $model;
2929
}
30-
31-
private static function transform($input) {
32-
$hash = null;
33-
$salt = null;
34-
35-
$pepper = Common::$config->bnetdocs->user_password_pepper;
36-
37-
$gmp = gmp_init(time());
38-
$gmp = gmp_mul($gmp, mt_rand());
39-
$gmp = gmp_mul($gmp, gmp_random_bits(64));
40-
$salt = strtoupper(gmp_strval($gmp, 36));
41-
42-
$hash = strtoupper(hash('sha256', $input.$salt.$pepper));
43-
44-
return [ $hash, $salt ];
45-
}
4630
}
+37-54
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,39 @@
1-
<?php
2-
1+
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
32
namespace BNETDocs\Templates\User;
4-
3+
use \CarlBennett\MVC\Libraries\Common;
54
use \CarlBennett\MVC\Libraries\Pair;
6-
7-
$title = "Create Password";
8-
$description = "This form allows an individual to create a password hash and salt for their account. DEVELOPMENT PURPOSES ONLY";
9-
$this->opengraph->attach(new Pair("url", "/user/createpassword"));
10-
11-
require("./header.inc.phtml");
12-
?>
13-
<article>
14-
<header>Create Password</header>
15-
<form method="POST" action="?">
16-
<section>
17-
<p>This form is for creating a password to your user account. It generates values that need to be given to the BNETDocs Staff for facilitating your account's creation or password reset.</p>
18-
</section>
19-
<section>
20-
<label for="input">Password:</label><br/>
21-
<input
22-
type="password"
23-
name="input"
24-
id="input"
25-
value="<?php echo filter_var($this->getContext()->input, FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?>"
26-
tabindex="1"
27-
required
28-
autofocus="autofocus"
29-
/>
30-
</section>
31-
<section>
32-
<input
33-
type="submit"
34-
value="Get Hash &amp; Salt"
35-
tabindex="2"
36-
/>
37-
</section>
38-
</form>
39-
<?php if (!empty($this->getContext()->output)) { ?>
40-
</article>
41-
<article>
42-
<header class="green">Secret Data</header>
43-
<section class="green">
44-
<p>These values with your email address or username must be given to BNETDocs Staff, message them now.</p>
45-
<table>
46-
<thead></thead>
47-
<tbody>
48-
<tr><th>Hash:</th><td><code><?php echo filter_var($this->getContext()->output[0], FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></code></td></tr>
49-
<tr><th>Salt:</th><td><code><?php echo filter_var($this->getContext()->output[1], FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></code></td></tr>
50-
</tbody>
51-
</table>
52-
<p>Please allow BNETDocs Staff a few moments to put these values into your account.</p>
53-
</section>
54-
<?php } ?>
55-
</article>
56-
<?php require("./footer.inc.phtml"); ?>
5+
$title = 'Create Password';
6+
$description = 'This page creates a password suitable for a user account.';
7+
$this->opengraph->attach(new Pair('url', '/user/createpassword'));
8+
$output = $this->getContext()->output;
9+
require('./header.inc.phtml'); ?>
10+
<div class="container">
11+
<h1><?=$title?></h1>
12+
<p><?=$description?></p>
13+
<div class="alert alert-info"><p class="mb-0">Our <a href="<?=Common::relativeUrlToAbsolute('/privacy')?>">privacy notice</a> page clarifies your data rights. You agree to giving (or not giving) the info contained herein on this page.</p></div>
14+
<div class="alert alert-warning"><p class="mb-0"><strong>Warning:</strong> This page is to be used with permission by site staff only. Use without permission is <strong>prohibited</strong> and may result in this page being shutdown in the future.</p></div>
15+
<form method="POST" action="?">
16+
<div class="form-group">
17+
<label class="font-weight-bold" for="input">Password:</label><br/>
18+
<input class="bg-dark border border-primary form-control text-light" type="password" name="input" id="input" placeholder="Enter the password here" value="<?=filter_var($this->getContext()->input, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>" tabindex="1" required autocomplete="new-password" autofocus="autofocus"/>
19+
</div>
20+
<div class="form-group">
21+
<input class="btn btn-success" type="submit" value="Submit" tabindex="2"/>
22+
</div>
23+
</form>
24+
<? if (!empty($output)) { ?>
25+
<div class="container border border-success p-2 rounded">
26+
<h3 class="text-success">Output</h3>
27+
<? if (is_string($output)) { ?>
28+
<pre><code class="language-plaintext"><?=filter_var($output, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></code></pre>
29+
<? } else { ?>
30+
<ul>
31+
<li><strong>Hash:</strong> <code><?=filter_var($output[0], FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></code></li>
32+
<li><strong>Salt:</strong> <code><?=filter_var($output[1], FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></code></li>
33+
</ul>
34+
<? } ?>
35+
<p class="mb-0">Please copy the output above and send it to the staff member for integration into your user account.</p>
36+
</div>
37+
<? } ?>
38+
</div>
39+
<? require('./footer.inc.phtml'); ?>

0 commit comments

Comments
 (0)