summaryrefslogtreecommitdiffstats
path: root/application/controllers/user.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-04-08 23:13:15 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-04-09 20:47:36 +0200
commit3f01ddce9dff69a49493541882de85854cbcebe5 (patch)
tree13c23f0a6893970ca71fbbfe763c3c696c8a0a4b /application/controllers/user.php
parentb18f4e453ecdf3404a107f9fc72d7bd9249401d0 (diff)
start working on users
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/user.php')
-rw-r--r--application/controllers/user.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/application/controllers/user.php b/application/controllers/user.php
new file mode 100644
index 000000000..4dc92bea2
--- /dev/null
+++ b/application/controllers/user.php
@@ -0,0 +1,74 @@
+<?php
+
+class User extends CI_Controller {
+
+ function __construct()
+ {
+ parent::__construct();
+ $this->load->library('migration');
+ if ( ! $this->migration->current()) {
+ show_error($this->migration->error_string());
+ }
+
+ $this->load->model("muser");
+ $this->data["title"] = "FileBin";
+
+ $this->load->helper('form');
+
+ $this->var->view_dir = "user/";
+ }
+
+ function index()
+ {
+ $this->data["username"] = $this->muser->get_username();
+
+ $this->load->view($this->var->view_dir.'header', $this->data);
+ $this->load->view($this->var->view_dir.'index', $this->data);
+ $this->load->view($this->var->view_dir.'footer', $this->data);
+ }
+
+ function login()
+ {
+ $this->session->keep_flashdata("uri");
+
+ if ($this->input->post('process')) {
+ $username = $this->input->post('username');
+ $password = $this->input->post('password');
+
+ $result = $this->muser->login($username, $password);
+
+ if ($result !== true) {
+ $data['login_error'] = true;
+ $this->load->view($this->var->view_dir.'header', $this->data);
+ $this->load->view($this->var->view_dir.'login', $this->data);
+ $this->load->view($this->var->view_dir.'footer', $this->data);
+ } else {
+ $uri = $this->session->flashdata("uri");
+ if ($uri) {
+ redirect($uri);
+ } else {
+ $this->load->view($this->var->view_dir.'header', $this->data);
+ $this->load->view($this->var->view_dir.'login_successful', $this->data);
+ $this->load->view($this->var->view_dir.'footer', $this->data);
+ }
+ }
+ } else {
+ $this->load->view($this->var->view_dir.'header', $this->data);
+ $this->load->view($this->var->view_dir.'login', $this->data);
+ $this->load->view($this->var->view_dir.'footer', $this->data);
+ }
+ }
+
+ function logout()
+ {
+ $this->muser->logout();
+ redirect('/');
+ }
+
+ function hash_password()
+ {
+ $password = $this->input->post("password");
+ echo "hashing $password: ";
+ echo $this->muser->hash_password($password);
+ }
+}