From 3a82baec9d793edf81ac2b151b0f4d4159641375 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 1 Apr 2024 11:09:25 -0400 Subject: login and register, liking on homepage --- src/web/_controller/apps/auth.php | 56 ++++++++++++++++++++++++++++++++++++++ src/web/_controller/apps/error.php | 21 ++++++++++++++ src/web/_controller/apps/home.php | 26 ++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 src/web/_controller/apps/auth.php create mode 100644 src/web/_controller/apps/error.php create mode 100644 src/web/_controller/apps/home.php (limited to 'src/web/_controller/apps') diff --git a/src/web/_controller/apps/auth.php b/src/web/_controller/apps/auth.php new file mode 100644 index 0000000..6b30cc9 --- /dev/null +++ b/src/web/_controller/apps/auth.php @@ -0,0 +1,56 @@ +auth_model = $this->load->model('apps/auth'); + } + + public function index(): void { + if ($this->main->session) { + $this->redirect('/home'); + } else { + $this->redirect('/auth/login'); + } + } + + public function login(): void { + if ($this->main->session) { + $this->redirect('/home'); + } + + parent::index(); + $data = $this->auth_model->get_data(); + $this->view('header_empty', $data); + $this->view('apps/auth/login', $data); + $this->view('footer', $data); + } + + public function logout(): void { + if ($this->main->session) { + $_SESSION['jwt'] = NULL; + } + $this->redirect('/auth/login'); + } + + public function update(): void { + if (!$this->is_ajax()) { + $this->error(400); + } + if (!isset($_POST['key']) || !isset($_POST['value'])) { + $this->error(400); + } + $key = $_POST['key']; + $value = $_POST['value']; + $_SESSION[$key] = $value; + } + +} + +?> diff --git a/src/web/_controller/apps/error.php b/src/web/_controller/apps/error.php new file mode 100644 index 0000000..03bbd8d --- /dev/null +++ b/src/web/_controller/apps/error.php @@ -0,0 +1,21 @@ +error_model = $this->load->model('apps/error'); + } + + public function index(): void { + parent::index(); + $data = $this->error_model->get_data(); + $this->view('header', $data); + $this->view('apps/error/main', $data); + $this->view('footer', $data); + } + +} + +?> diff --git a/src/web/_controller/apps/home.php b/src/web/_controller/apps/home.php new file mode 100644 index 0000000..c9a116d --- /dev/null +++ b/src/web/_controller/apps/home.php @@ -0,0 +1,26 @@ +home_model = $this->load->model('apps/home'); + $this->post_controller = $this->load->controller('_util/post'); + } + + public function index(): void { + parent::index(); + $data = $this->home_model->get_data(); + $this->view('header', $data); + $this->view('apps/home/main', $data); + $this->view('footer', $data); + } + +} + +?> -- cgit v1.2.3-freya