Я использую библиотеку Ion Auth Auth с CodeIgniter и создал вход в систему, зарегистрируйтесь, запомните меня и забыл функции пароля (до сих пор). < /p>
Для функции забытого пароля типы пользователей в своем адресе электронной почты они отправляются по электронной почте со ссылкой на сброс пароля. Ошибка в моем журнале PHP: < /p>
PHP Fatal error: Call to undefined method Auth::_valid_csrf_nonce() in /Applications/MAMP/htdocs/Auth/application/controllers/auth.php on line 273
< /code>
Я ничего не изменил при загрузке этой библиотеки, поэтому задаюсь вопросом, куда я ошибаюсь?function _get_csrf_nonce()
{
$this->load->helper('string');
$key = random_string('alnum', 8);
$value = random_string('alnum', 20);
$this->session->set_flashdata('csrfkey', $key);
$this->session->set_flashdata('csrfvalue', $value);
return array($key => $value);
}
//reset password - final step for forgotten password
public function reset_password($code = NULL)
{
if (!$code)
{
show_404();
}
$user = $this->ion_auth->forgotten_password_check($code);
if ($user)
{
//if the code is valid then display the password reset form
$this->form_validation->set_rules('new', 'New Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]');
$this->form_validation->set_rules('new_confirm', 'Confirm New Password', 'required');
if ($this->form_validation->run() == false)
{
//display the form
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['min_password_length'] = $this->config->item('min_password_length', 'ion_auth');
$this->data['new_password'] = array(
'name' => 'new',
'id' => 'new',
'type' => 'password',
'pattern' => '^.{'.$this->data['min_password_length'].'}.*$'
);
$this->data['new_password_confirm'] = array(
'name' => 'new_confirm',
'id' => 'new_confirm',
'type' => 'password',
'pattern' => '^.{'.$this->data['min_password_length'].'}.*$'
);
$this->data['user_id'] = array(
'name' => 'user_id',
'id' => 'user_id',
'type' => 'hidden',
'value' => $user->id
);
$this->data['csrf'] = $this->_get_csrf_nonce();
$this->data['code'] = $code;
//render
$this->_render_page('reset_password', $this->data);
}
else
{
// do we have a valid request?
if ($this->_valid_csrf_nonce() === FALSE || $user->id != $this->input->post('user_id'))
{
//something fishy might be up
$this->ion_auth->clear_forgotten_password_code($code);
show_error('This form post did not pass our security checks.');
}else{
// finally change the password
$identity = $user->{$this->config->item('identity', 'ion_auth')};
$change = $this->ion_auth->reset_password($identity, $this->input->post('new'));
if ($change)
{
//if the password was successfully changed
$this->session->set_flashdata('message', $this->ion_auth->messages());
$this->logout();
}else{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('reset_password/' . $code, 'refresh');
}
}
}
}
else
{
//if the code is invalid then send them back to the forgot password page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("forgot_password", 'refresh');
}
}
< /code>
Функция модели забытого пароля: < /p>
/**
* Forgotten Password Complete
*
* @return string
* @author Mathew
**/
public function forgotten_password_complete($code, $salt=FALSE)
{
$this->trigger_events('pre_forgotten_password_complete');
if (empty($code))
{
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
$profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile
if ($profile) {
if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0) {
//Make sure it isn't expired
$expiration = $this->config->item('forgot_password_expiration', 'ion_auth');
if (time() - $profile->forgotten_password_time > $expiration) {
//it has expired
$this->set_error('forgot_password_expired');
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
}
$password = $this->salt();
$data = array(
'password' => $this->hash_password($password, $salt),
'forgotten_password_code' => NULL,
'active' => 1,
);
$this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code));
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_successful'));
return $password;
}
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
< /code>
Сбросить пароль Просмотр пароля: < /p>
New Password (at least characters long):
Confirm New Password:
Подробнее здесь: https://stackoverflow.com/questions/148 ... t-password
CodeIgniter: пароль сброса ионной авторизации ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1758747895
Anonymous
Я использую библиотеку Ion Auth Auth с CodeIgniter и создал вход в систему, зарегистрируйтесь, запомните меня и забыл функции пароля (до сих пор). < /p>
Для функции забытого пароля типы пользователей в своем адресе электронной почты они отправляются по электронной почте со ссылкой на сброс пароля. Ошибка в моем журнале PHP: < /p>
PHP Fatal error: Call to undefined method Auth::_valid_csrf_nonce() in /Applications/MAMP/htdocs/Auth/application/controllers/auth.php on line 273
< /code>
Я ничего не изменил при загрузке этой библиотеки, поэтому задаюсь вопросом, куда я ошибаюсь?function _get_csrf_nonce()
{
$this->load->helper('string');
$key = random_string('alnum', 8);
$value = random_string('alnum', 20);
$this->session->set_flashdata('csrfkey', $key);
$this->session->set_flashdata('csrfvalue', $value);
return array($key => $value);
}
//reset password - final step for forgotten password
public function reset_password($code = NULL)
{
if (!$code)
{
show_404();
}
$user = $this->ion_auth->forgotten_password_check($code);
if ($user)
{
//if the code is valid then display the password reset form
$this->form_validation->set_rules('new', 'New Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]');
$this->form_validation->set_rules('new_confirm', 'Confirm New Password', 'required');
if ($this->form_validation->run() == false)
{
//display the form
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['min_password_length'] = $this->config->item('min_password_length', 'ion_auth');
$this->data['new_password'] = array(
'name' => 'new',
'id' => 'new',
'type' => 'password',
'pattern' => '^.{'.$this->data['min_password_length'].'}.*$'
);
$this->data['new_password_confirm'] = array(
'name' => 'new_confirm',
'id' => 'new_confirm',
'type' => 'password',
'pattern' => '^.{'.$this->data['min_password_length'].'}.*$'
);
$this->data['user_id'] = array(
'name' => 'user_id',
'id' => 'user_id',
'type' => 'hidden',
'value' => $user->id
);
$this->data['csrf'] = $this->_get_csrf_nonce();
$this->data['code'] = $code;
//render
$this->_render_page('reset_password', $this->data);
}
else
{
// do we have a valid request?
if ($this->_valid_csrf_nonce() === FALSE || $user->id != $this->input->post('user_id'))
{
//something fishy might be up
$this->ion_auth->clear_forgotten_password_code($code);
show_error('This form post did not pass our security checks.');
}else{
// finally change the password
$identity = $user->{$this->config->item('identity', 'ion_auth')};
$change = $this->ion_auth->reset_password($identity, $this->input->post('new'));
if ($change)
{
//if the password was successfully changed
$this->session->set_flashdata('message', $this->ion_auth->messages());
$this->logout();
}else{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('reset_password/' . $code, 'refresh');
}
}
}
}
else
{
//if the code is invalid then send them back to the forgot password page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("forgot_password", 'refresh');
}
}
< /code>
Функция модели забытого пароля: < /p>
/**
* Forgotten Password Complete
*
* @return string
* @author Mathew
**/
public function forgotten_password_complete($code, $salt=FALSE)
{
$this->trigger_events('pre_forgotten_password_complete');
if (empty($code))
{
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
$profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile
if ($profile) {
if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0) {
//Make sure it isn't expired
$expiration = $this->config->item('forgot_password_expiration', 'ion_auth');
if (time() - $profile->forgotten_password_time > $expiration) {
//it has expired
$this->set_error('forgot_password_expired');
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
}
$password = $this->salt();
$data = array(
'password' => $this->hash_password($password, $salt),
'forgotten_password_code' => NULL,
'active' => 1,
);
$this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code));
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_successful'));
return $password;
}
$this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful'));
return FALSE;
}
< /code>
Сбросить пароль Просмотр пароля: < /p>
New Password (at least characters long):
Confirm New Password:
Подробнее здесь: [url]https://stackoverflow.com/questions/14853834/codeigniter-ion-auth-reset-password[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия