1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Controllers; |
4 | | | |
5 | | | use Phem\Environment\Application; |
6 | | | use Phem\Environment\ApplicationException; |
7 | | | use Phem\Environment\EnvironmentManager; |
8 | | | use Phem\Environment\Message; |
9 | | | |
10 | | | /** |
11 | | | * |
12 | | | * @author kubapet |
13 | | | */ |
14 | | | class DispatcherController extends SimpleViewController |
15 | | | { |
16 | | | |
17 | | | public function login($username, $password) |
18 | | | { |
19 | | | if (($username != null) && ($password != null)) |
20 | | | { |
21 | | | $ap = EnvironmentManager::getAuthenticationProvider(); |
22 | | | $user = $ap->authenticate($username, $password); |
23 | | | if ($user != null) |
24 | | | { |
25 | | | EnvironmentManager::getSession()->setVar(ROOT_NAMESPACE . ".loggedUser", $user->getUsername()); |
26 | | | |
27 | | | /*$msg = new Message(); |
28 | | | $msg->setFromUsr($user->getUsername()); |
29 | | | $msg->setSubject('PĹĂchod uĹživatele ' . $user->getUsername()); |
30 | | | |
31 | | | try |
32 | | | { |
33 | | | Application::notify($msg); |
34 | | | } |
35 | | | catch (ApplicationException $ex) |
36 | | | { |
37 | | | |
38 | | | }*/ |
39 | | | |
40 | | | $this->redirectToController = DEFAULT_CONTROLLER; |
41 | | | $this->redirectToTask = DEFAULT_TASK; |
42 | | | return; |
43 | | | } |
44 | | | } |
45 | | | |
46 | | | $lb = EnvironmentManager::getLinkBuilder(); |
47 | | | $this->getModel()->set("formAction", $lb->link(array("controller" => "Dispatcher", "task" => "login"))); |
48 | | | $this->template = "@Phem/login.twig"; |
49 | | | } |
50 | | | |
51 | | | public function logout() |
52 | | | { |
53 | | | EnvironmentManager::getSession()->setVar(ROOT_NAMESPACE . ".loggedUser", null); |
54 | | | $this->renderTemplate = false; |
55 | | | $this->redirectToController = "Disparcher"; |
56 | | | $this->redirectToTask = "login"; |
57 | | | return; |
58 | | | } |
59 | | | |
60 | | | public function showAccessDenied() |
61 | | | { |
62 | | | |
63 | | | } |
64 | | | |
65 | | | } |