1
0
Fork 0
mirror of https://github.com/Oreolek/kangana.git synced 2024-07-05 08:04:27 +03:00
kangana/application/classes/Task/Password.php

38 lines
1,020 B
PHP
Raw Normal View History

2014-01-30 07:40:49 +02:00
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* This is a task to change admin's password.
* It can accept -password option.
* @category Helpers
* @author Oreolek
* @license AGPL
**/
class Task_Password extends Minion_Task
{
protected $_options = array(
'user' => 'admin',
'password' => NULL,
);
public function build_validation(Validation $validation)
{
return parent::build_validation($validation)
->rule('password', 'not_empty'); // Require this param
}
/**
* This is an admin password task
*
* @return null
*/
protected function _execute(array $params)
{
$writer = new Config_File_Writer;
Kohana::$config->attach($writer);
$config = Kohana::$config->load('auth');
2014-01-31 10:15:50 +02:00
$hash = hash_hmac($config->get('hash_method'), $params['password'], $config->get('hash_key'));
2014-01-30 07:40:49 +02:00
$config->set('users', array($params['user'] => $hash));
Kohana::$config->detach($writer);
echo __('The password was successfully changed.');
}
}