0

我正在通过代码点火器建立一个社交网络。注册后,潜在成员获取存储在数据库中,并且他们的状态获取标记为待处理。然后我向他们发送一封带有哈希令牌链接的确认电子邮件。当他们点击链接时,它会将他们的帐户标记为活动,并将他们带到一个有登录的欢迎页面。

当我转到链接时,它会设置一个无限循环并在我处理 MAMP 时冻结我的计算机。(或者我怀疑这是一个无限循环)

这是我的相关代码:

发送电子邮件的身份验证控制器:

function varification_email()
{
    $query = $this->db->query('SELECT * FROM users order by id desc LIMIT 1');
    $token = sha1($user->email.$user->salt).dechex($user->id);
    $domain = "clci.dev/index.php";
    $link = "http://www.".$domain."/account/confirmation/?token=$token";
    foreach ($query->result() as $user)
    {
        $this->load->library('email');

        $this->email->from('noreply@cysticlife.org', 'CysticLife');
        $this->email->to($user->email); 

        $this->email->subject('Welcome to CysticLife!');
        $this->email->message("Thanks for signing up for CysticLife! To complete the registration process please go to the following web address:\n\n$link\n\n-Your friends at CysticLife\n\nPlease remember to add the cysticlife.org domain to your address book to ensure that you receive your CysticLife e-Notifications as requested.eh");    

        $this->email->send();
}

用户从电子邮件链接回的帐户 CONTROLLER:

public function confirmation() {
    $data['main_content'] = 'account/confirmation';
    $this->load->view('includes/templates/main_page_template', $data);
    $this->load->library('encrypt');
    $this->load->helper('url');
    $this->load->library('session');
    $this->load->model('user_model', 'um');
    $login = $this->input->post('submit');


    //IF THE SUBMIT BUTTON IS TRIGGERED THE POST DATA IS SENT TO THE VALIDATE FUNCTION IN THE MODEL VIA VARIABLES CREATED 
    if($login) {
        $user = $this->um->validate(array('email' => $this->input->post('email')));
        if( $user ) {
            // CHECK THE USER'S PASSWORD AGAINST THE ONE FROM THE LOGIN FORM
            if($user->password == $this->encrypt->sha1( $user->salt . $this->encrypt->sha1($this->input->post('password')))) {
                $this->session->set_userdata('logged_in', TRUE);
                $this->session->set_userdata(array(
                    'email' => $this->input->post('email')
                ));
                $this->session->userdata('logged_in');
                redirect('account/dashboard');
                exit;
            }
        }
    }

    $this->index();
}

提前致谢

4

1 回答 1

0

验证电子邮件()

  • 在 v rification_email () 中,$user在定义之前使用它。我认为真正的代码没有这个问题。
  • 您在数据库中选择用户的方法容易出现并发错误(返回错误的用户)。

确认()

  • 我已经遇到过由于 cookie 太大而导致浏览器挂起的情况,超过了 4 kB。看看那个。
  • 问题可能出在user_model->validate(). 注释掉以下代码并检查它是否有效。
于 2012-09-03T01:46:24.643 回答