-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUserController.php
More file actions
43 lines (35 loc) · 1.02 KB
/
UserController.php
File metadata and controls
43 lines (35 loc) · 1.02 KB
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
40
41
42
43
<?php
class UserController {
public function index() {
global $userManager, $firewall;
if ($firewall->hasUserAccess())
include_once __DIR__ . "/templates/user/index.phtml";
else {
header("HTTP/1.1 403 Forbidden");
include_once __DIR__ . "/templates/403.phtml";
}
}
public function editPassword() {
global $userManager, $firewall;
include_once __DIR__."/templates/user/edit.phtml";
}
public function updatePassword() {
global $userManager;
if ($_SERVER['REQUEST_METHOD'] === "POST") {
$message = '';
$success = false;
try {
$user = $userManager->getCurrentUser();
$user->setPassword($_POST['password']);
$success = $userManager->updateUser($user);
} catch(Exception $e) {
$message = $e->getMessage();
}
header("HTTP/1.1 303 See Other");
header("Location: {$_SERVER["SCRIPT_NAME"]}?action=changePassword&success=".(int)$success."&message=".urlencode($message));
} else {
header("HTTP/1.1 403 Forbidden");
include_once __DIR__ . "/templates/403.phtml";
}
}
}