/** * email a reset credential link to the a user * * @param object $fc * @return void * @author Andy Bennett */ public function forgotten_credential($fc) { $this->prep_formdata($fc); // check that a user with the passed email exists $data = $fc->data[$this->table]; $this->db->select('*')->from($this->table); $this->db->where(array('email' => $data['email'], 'activated' => 1)); $q = $this->db->get(); if (!$q->count()) { throw new Exception('<span class="form-error">' . Kohana::lang('auth.no_matching_email') . '</span>'); } //generates the activation code $forgotten_credential_code = steamauth_helper::generate_random_string(10, 10); // updates the user table with the code $sql = 'UPDATE ' . $this->table . ' SET `forgotten_credential_code`="' . $forgotten_credential_code . '" WHERE `id`="' . $q->current()->id . '"'; $this->db->query($sql); // get the current segment array $uri = implode('/', array_slice(Kohana::instance()->uri->segment_array(), 0, -1)); // get the column names $identity = $this->conf->identity_column; // run the email event $email_data = array('row' => $q->current(), 'forgotten_credential_code' => $forgotten_credential_code); Event::run('steamauth.forgotten_credential_email', $email_data); return true; }