-
Notifications
You must be signed in to change notification settings - Fork 342
Expand file tree
/
Copy pathHashPassword.php
More file actions
39 lines (32 loc) · 840 Bytes
/
HashPassword.php
File metadata and controls
39 lines (32 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace Selfoss\controllers\Helpers;
use Selfoss\helpers\Authentication;
use Selfoss\helpers\View;
/**
* Controller for user related tasks
*/
final readonly class HashPassword {
public function __construct(
private Authentication $authentication,
private View $view
) {
}
/**
* password hash generator
* json
*/
public function hash(): void {
$this->authentication->ensureIsPrivileged();
if (!isset($_POST['password'])) {
$this->view->jsonError([
'success' => false,
'error' => 'No password given.',
]);
}
$this->view->jsonSuccess([
'success' => true,
'hash' => password_hash($_POST['password'], PASSWORD_DEFAULT),
]);
}
}