public function activate_admin() { $mail_key = $this->request->params['key']; if (!valid_hash($mail_key)) { die("Передан неверный ключ активации!"); } else { $this->loadModel('Admin'); $find_user = $this->Admin->find('first', array('conditions' => array('mail_key' => $mail_key))); if (count($find_user) == 0) { die("Пользователь не найден!"); } else { if ($find_user['Admin']['mail_checked'] == 0) { $this->Admin->id = $find_user['Admin']['id']; $this->Admin->save(array('mail_checked' => 1)); $this->Admin->save(); $this->redirect(array('controller' => 'activate_account', 'action' => 'account_activated')); exit; } else { die("Аккаунт уже активирован!"); } } } }
public function setup_password() { $key = $this->params->key; if (!valid_hash($key)) { die(L('RECOVERY_KEY_NOT_HASH')); } //поиск ключа по базе $find_user = $this->User->find('first', array('conditions' => array('mail_key' => $key))); if (count($find_user) == 0) { $this->redirect(array('controller' => 'recovery', 'action' => 'failed')); exit; } else { //форма смены пароля $fio = prepare_fio($find_user['User']['firstname'], $find_user['User']['lastname'], $find_user['User']['fathername']); $image = $find_user['User']['main_foto']; $this->set('fio', $fio); $this->set('main_image', $image); $this->set('mail', $find_user['User']['mail']); $this->set('recover_user_id', $find_user['User']['id']); $this->Session->write('recover_user_id', $find_user['User']['id']); $this->Session->write('mail', $find_user['User']['mail']); } }