From e4768cd0647d934eff424f73bfd9f5c8f6223c94 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Mon, 12 Nov 2018 13:55:40 +0100 Subject: link+log --- app/class/controllerconnect.php | 52 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'app/class/controllerconnect.php') diff --git a/app/class/controllerconnect.php b/app/class/controllerconnect.php index 2bda1b0..da3c96f 100644 --- a/app/class/controllerconnect.php +++ b/app/class/controllerconnect.php @@ -3,11 +3,59 @@ class Controllerconnect extends Controller { - public function desktop() + public function log() { - $this->showtemplate('connect', ['user' => $this->user]); + if (isset($_POST['log'])) { + if (isset($_POST['id'])) { + $id = $_POST['id']; + } else { + $id = null; + } + if ($_POST['log'] === 'login') { + $this->login($id); + } elseif ($_POST['log'] === 'logout') { + $this->logout($id); + } + } + + } + + + public function connect() + { + $this->showtemplate('connect', []); } + + + + + public function login($id) + { + if (isset($_POST['pass'])) { + $this->user = $this->usermanager->login($_POST['pass']); + $this->usermanager->writesession($this->user); + } + if (!empty($id)) { + $this->routedirect('artedit', ['art' => $id]); + } else { + $this->routedirect('backrouter'); + } + } + + public function logout($id) + { + $this->user = $this->usermanager->logout(); + $this->usermanager->writesession($this->user); + if (!empty($id)) { + $this->routedirect('artread/', ['art' => $id]); + } else { + $this->routedirect('backrouter'); + } + } + + + } -- cgit v1.2.3