mirror of
https://github.com/Ekokumppanit/ystavakylaecard.git
synced 2026-01-26 03:04:00 +00:00
Admins can now change passwords
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -96,6 +96,49 @@ if ($user->can_seeusers == "no") {
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row">
|
||||
<form action="<?php echo $post_url."/password/".$userid; ?>" method="post"
|
||||
accept-charset="utf-8" id="user_password" class="custom">
|
||||
<input type="hidden" name="from_page" value="<?php echo current_url(); ?>">
|
||||
<div clas="large-12 small-12 columns">
|
||||
<div class="panel">
|
||||
<h3>Salasana</h3>
|
||||
<div class="row">
|
||||
<div class="large-6 small-12 columns">
|
||||
<?php
|
||||
$password = array(
|
||||
'id' => 'password',
|
||||
'name' => 'password',
|
||||
'minlength' => "2",
|
||||
'value' => '',
|
||||
'required' => null
|
||||
);
|
||||
echo form_label('Salasana', 'password') . "\n";
|
||||
echo form_password($password) . "\n";
|
||||
?>
|
||||
</div>
|
||||
<div class="large-6 small-12 columns">
|
||||
<?php
|
||||
$password['id'] = 'password_again';
|
||||
$password['name'] = 'password_again';
|
||||
echo form_label('Salasana uudelleen', 'password_again') . "\n";
|
||||
echo form_password($password) . "\n";
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
echo form_submit(
|
||||
array(
|
||||
'name' => 'savepassword',
|
||||
'value' => 'Tallenna uusi salasana',
|
||||
'class' => 'button small large-12 small-12'
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@ jQuery(document).ready(function($) {
|
||||
}
|
||||
});
|
||||
|
||||
// Trigger jQuery validation of user password form
|
||||
$('#user_password').validate({
|
||||
rules: {
|
||||
password: "required",
|
||||
password_again: {
|
||||
equalTo: "#password"
|
||||
}
|
||||
},
|
||||
submitHandler: function(form) {
|
||||
form.submit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user