Codeigniter と Ion Auth Library を使用するサイトを作成しています。
登録/ログイン/忘れたパスワードを設定しましたが、これらはすべて忘れたパスワードの設定の問題とは別に機能します。
ユーザーの電子メール アドレスが hotmail、yahoo、gmail などを使用している場合、電子メールを正常に受信し、パスワードをリセットしてデータベース内のデータを変更できます。
Outlook とメールでこのメールを受信する個人ドメインのメール アドレスに問題があるため、Exchange と関係があるように見えますか?
また、Outlook を搭載したコンピューターでログ設定を有効にしました。テスト送信時にメールがログに記録されないため、メールがブロックされているわけではありません。
今、私は電子メール構成設定の配列を持っていますが、それがホスト、プロトコル、ヘッダーと関係があるかどうかはわかりません?! またはその他の設定ですが、私が持っているものに以下の情報を提供します。誰かが情報、リンク、スニペット、またはアイデアを持っている場合、これは大きな助けになります.
Ion Auth を使用して、コードを元の場所に保持し、構成ファイルの設定に変更しました。
設定
$config['use_ci_email'] = FALSE; // Send Email using the builtin CI email class, if false it will return the code and the identity
$config['email_config'] = array(
'protocol'=> 'mail',
'mailtype' => 'html',
'charset' =>'utf-8',
'smpt_host' =>'smpt.url.com',
'smpt_user'=> 'ssl://smtp.live.com',
'smtp_port' => '25',
'validate' => TRUE,
'priority' => 1
);
パスワードを忘れた場合のコントローラ:
//forgot password
function forgot_password() {
$this->form_validation->set_rules('email', 'Email Address', 'required');
if ($this->form_validation->run() == false) {
//setup the input
$this->data['email'] = array('name' => 'email',
'id' => 'email',
);
if ( $this->config->item('identity', 'ion_auth') == 'username' ){
$this->data['identity_label'] = 'Username';
}else{
$this->data['identity_label'] = 'Email';
}
//set any errors and display the form
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->_render_page('forgot_password', $this->data);
}else{
// get identity for that email
$config_tables = $this->config->item('tables', 'ion_auth');
$identity = $this->db->where('email', $this->input->post('email'))->limit('1')->get($config_tables['users'])->row();
//run the forgotten password method to email an activation code to the user
$forgotten = $this->ion_auth->forgotten_password($identity->{$this->config->item('identity', 'ion_auth')});
if ($forgotten) {
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("login", 'refresh'); //we should display a confirmation page here instead of the login page
}else{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("forgot_password", 'refresh');
}
}
}
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);
}
パスワードを忘れた場合のライブラリ関数:
/**
* forgotten password feature
**/
public function forgotten_password($identity) //changed $email to $identity
{
if ( $this->ion_auth_model->forgotten_password($identity) ) //changed
{
// Get user information
$user = $this->where($this->config->item('identity', 'ion_auth'), $identity)->users()->row(); //changed to get_user_by_identity from email
if ($user)
{
$data = array(
'identity' => $user->{$this->config->item('identity', 'ion_auth')},
'forgotten_password_code' => $user->forgotten_password_code
);
if(!$this->config->item('email_config', 'ion_auth'))
{
$this->set_message('forgot_password_successful');
return $data;
}
else
{
$message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password', 'ion_auth'), $data, true);
$this->email->clear();
$this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
$this->email->to($user->email);
$this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject'));
$this->email->message($message);
if ($this->email->send())
{
$this->set_message('forgot_password_successful');
return TRUE;
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}
else
{
$this->set_error('forgot_password_unsuccessful');
return FALSE;
}
}