Skip to content

Instantly share code, notes, and snippets.

@converge
Created April 2, 2015 12:43
Show Gist options
  • Save converge/2ba1a0b51fb717a08095 to your computer and use it in GitHub Desktop.
Save converge/2ba1a0b51fb717a08095 to your computer and use it in GitHub Desktop.
public function resetPasswords() {
$users = $this->User->find('all', array(
'conditions' => array('username REGEXP' => '[0-9]+')
)
);
foreach ($users as $user => $item) {
$this->User->read(null, $item['User']['id']);
//$newPasswd = $this->Auth->password(substr($item['User']['username'], 0, 4));
$newPasswd = $this->Auth->password('2222');
$this->User->set(array('User.password' => $newPasswd));
$this->User->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment