From 59ee192e1da6f19d5a742c2da52578076557181a Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Wed, 17 Jul 2013 14:39:33 +0300 Subject: [PATCH] Admins can now change passwords --- application/controllers/yllapito.php | 6 ++++ application/models/user_model.php | 10 ++++++ application/views/yllapito/users_show.php | 43 +++++++++++++++++++++++ assets/js/scripts.js | 8 +++++ 4 files changed, 67 insertions(+) diff --git a/application/controllers/yllapito.php b/application/controllers/yllapito.php index d221ef9..9fa8c97 100644 --- a/application/controllers/yllapito.php +++ b/application/controllers/yllapito.php @@ -152,6 +152,12 @@ class Yllapito extends CI_Controller $this->users->save($user_id, $data); redirect($from); break; + case 'password': + $data = $this->input->post(); + $from = $data['from_page']; + $this->users->savePassword($user_id, $data['password']); + redirect($from); + break; case 'show': $data['userid'] = $user_id; $data['userdata'] = $this->users->get($user_id); diff --git a/application/models/user_model.php b/application/models/user_model.php index 4f33e63..038a604 100644 --- a/application/models/user_model.php +++ b/application/models/user_model.php @@ -27,6 +27,16 @@ class User_model extends MY_Model return $this->update($uid, $data); } + public function savePassword($uid = null, $password = null) + { + if (empty($uid) || empty($password)) { + return false; + } + + $password = $this->passwordhash($password); + return $this->update($uid, array('password' => $password)); + } + public function passwordhash($password = null) { return hash( diff --git a/application/views/yllapito/users_show.php b/application/views/yllapito/users_show.php index 91364ec..6075618 100644 --- a/application/views/yllapito/users_show.php +++ b/application/views/yllapito/users_show.php @@ -96,6 +96,49 @@ if ($user->can_seeusers == "no") { +
+
" method="post" + accept-charset="utf-8" id="user_password" class="custom"> + +
+
+

Salasana

+
+
+ 'password', + 'name' => 'password', + 'minlength' => "2", + 'value' => '', + 'required' => null + ); + echo form_label('Salasana', 'password') . "\n"; + echo form_password($password) . "\n"; + ?> +
+
+ +
+
+ 'savepassword', + 'value' => 'Tallenna uusi salasana', + 'class' => 'button small large-12 small-12' + ) + ); + ?> +
+
+
+