From 5a2ba9c2e7605bb788bc406184547d22c6436867 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 23 Dec 2024 11:13:27 -0500 Subject: v2.1.0, refactor w/ crimson --- src/web/_controller/auth.php | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/web/_controller/auth.php (limited to 'src/web/_controller/auth.php') diff --git a/src/web/_controller/auth.php b/src/web/_controller/auth.php new file mode 100644 index 0000000..fd1931c --- /dev/null +++ b/src/web/_controller/auth.php @@ -0,0 +1,45 @@ +auth_model = $this->load_model('auth'); + $this->load_lang('auth'); + } + + public function index(): void { + $this->load_controller('index')->index(); + } + + public function login(): void { + if ($this->auth_model->session()) + $this->redirect('/home'); + + parent::index(); + $data = $this->auth_model->get_data(); + $this->view('head', $data); + $this->view('auth/main', $data); + $this->view('footer', $data); + } + + public function logout(): void { + if ($this->auth_model->session()) + $_SESSION['jwt'] = NULL; + $this->redirect('/auth/login'); + } + + public function update(): void { + $key = $this->post_data('key'); + $value = $this->post_data('value'); + + if (!$key || !$value) + $this->error(400); + + $_SESSION[$key] = $value; + } + +} + +?> -- cgit v1.2.3-freya