public function post_forgot_password() { $rules = Config::get('rules.forgot_password'); $validation = Validator::make(Input::get(), $rules); if ($validation->passes()) { $new_password = User::new_password(Input::get('email')); if (!$new_password) { return Event::first('500', 'Your password could not be changed due to a system error. We apologize for any inconvenience.'); } //$message = "Your password to log into <whatever site> has been temporarily changed to '$new_password'. Please log in using that password and this email address. Then you may change your password to something more familiar."; //mail(Input::get('email'), 'Your temporary password.', $message, 'From: admin@example.com'); Session::flash('success', TRUE); } return Redirect::to('forgot_password')->with_input()->with_errors($validation); }
function test_dont_create_same_email_that_other() { $data = array('username' => 'UsernameTest2', 'email' => $this->m_email_user, 'first_name' => 'First Name Test2', 'last_name' => 'Last Name Test2', 'password' => User::new_password('password')); $user = $this->sangar_auth->register($data); $this->_assert_false($user); }
function edit($id = FALSE) { //load block submit helper and append in the head $this->template->append_metadata(block_submit_button()); //get the $id $id = $this->uri->segment(4) ? $this->uri->segment(4) : $this->input->post('id', TRUE); //Filter & Sanitize $id $id = $id != 0 ? filter_var($id, FILTER_VALIDATE_INT) : NULL; //redirect if it´s no correct if (!$id) { $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_object_not_exist'))); redirect('/admin/users/'); } //Rules for validation $this->_set_rules('edit', $id); if ($this->form_validation->run() == FALSE) { $this->template->title(lang("web_edit_user")); $this->template->set('updType', 'edit'); $this->template->set('user', User::find_by_id($id)); $this->template->build('users/create_user'); } else { $data = array('username' => $this->input->post('email'), 'email' => $this->input->post('email'), 'first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name')); if ($this->input->post('password') != '') { $data['password'] = User::new_password($this->input->post('password')); } //find the item to update $user = User::find($this->input->post('id', TRUE)); $user->update_attributes($data); // run insert model to write data to db if ($user->is_valid()) { $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_edit_success'))); redirect('/admin/users/'); } if ($user->is_invalid()) { $this->session->set_flashdata('message', array('type' => 'error', 'text' => lang('web_edit_failed'))); redirect('/admin/users/'); } } }
} $f3->set('email', $user); echo Template::instance()->render('password.html'); }); $f3->route('POST /p/@key', function ($f3) { $key = $f3->get('PARAMS.key'); $user = User::find_pwreset($key); if (!$user) { $f3->error(404); } $pw = $_POST['password']; $pw2 = $_POST['password2']; if ($pw != $pw2) { $f3->reroute("/p/" . $key); } User::new_password($user, $pw); $_SESSION['message'] = "Password reset successfully."; $f3->reroute("/"); }); /***********************/ /**** For embedding ****/ /***********************/ $f3->route('GET /embed', function ($f3) { echo Template::instance()->render('calendar.html'); }); /***********************/ /**** Other formats ****/ /***********************/ $f3->route('GET /leaflet', function ($f3) { $where = "startdt >= date('now', 'start of day') AND state == 'approved'"; $f3->set('events', Events::load($where));