2016-06-24 49 views
0

我正在試圖讓我們的自定義代碼脫離核心。如何將此自定義代碼移出drupal核心用戶模塊?

在此功能中我捕捉到舊會話ID更新項目的用戶可能一直在努力,而不是在登錄

function user_authenticate_finalize(&$edit) { 
    global $user; 
    watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); 
    // Update the user table timestamp noting user has logged in. 
    // This is also used to invalidate one-time login links. 
    $user->login = time(); 
    db_query("UPDATE {users} SET login = %d WHERE uid = %d", $user->login, $user->uid); 

    $old_session_id = session_id(); //THIS LINE NEEDS TO BE MOVED 

    // Regenerate the session ID to prevent against session fixation attacks. 
    sess_regenerate(); 

    tf_user_new_session_id($user, $old_session_id); //THIS LINE NEEDS TO BE MOVED 

    user_module_invoke('login', $edit, $user); 
} 

右側前,後右sess_regenerate()的線條。

回答

0
function tf_user_user($op, &$edit, &$account, $category = NULL) 
{ 
    $current_session = session_id(); 

    if ('login' == $op) 
    { 
    setcookie('session_id_anonymous', $current_session, time() + 86400); 
    } 
    if ('load' == $op) 
    { 
    if (isset($_COOKIE['session_id_anonymous']) && $_COOKIE['session_id_anonymous'] != $current_session) 
    { 
     tf_user_new_session_id($account->uid, $_COOKIE['session_id_anonymous'], $current_session); 

     setcookie('session_id_anonymous', $current_session, time() - 3600); 
    } 
    } 
    //more code 
} 
0

據我所知,你將不得不編寫自己的登錄程序,以便在D6中完成這項工作。我可能會做一個hook_form_alter()並用我自己的登錄表單替換提交處理程序。