2012-09-05 13:46:24 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Reset a password
|
2012-09-18 15:30:32 +02:00
|
|
|
*
|
2012-09-05 13:46:24 +02:00
|
|
|
* arg0 = email
|
|
|
|
* arg1 = new password
|
|
|
|
*/
|
|
|
|
class PasswordShell extends AppShell {
|
2012-09-18 15:30:32 +02:00
|
|
|
|
2012-09-05 13:46:24 +02:00
|
|
|
public $uses = array('User');
|
|
|
|
|
|
|
|
public function main() {
|
|
|
|
// get the users that need their password hashed
|
2015-05-12 11:28:36 +02:00
|
|
|
$results = $this->User->find('first', array('conditions' => array('email' => $this->args[0])));
|
2012-09-05 13:46:24 +02:00
|
|
|
$results['User']['password'] = $this->args[1];
|
|
|
|
$results['User']['confirm_password'] = $this->args[1];
|
2015-05-12 11:28:36 +02:00
|
|
|
$results['User']['change_pw'] = 1;
|
2012-09-05 13:46:24 +02:00
|
|
|
|
|
|
|
if (!$this->User->save($results)) {
|
|
|
|
echo 'Could not update account for User.id = ', $results['User']['id'], PHP_EOL;
|
|
|
|
debug($this->User->validationErrors);
|
|
|
|
$this->out(print_r($this->User->invalidFields(), true));
|
|
|
|
}
|
|
|
|
|
2013-02-15 15:20:03 +01:00
|
|
|
echo 'Updated ', PHP_EOL;
|
2012-09-05 13:46:24 +02:00
|
|
|
exit;
|
|
|
|
}
|
2015-09-09 20:52:01 +02:00
|
|
|
}
|