2011-04-21 7 views

답변

4

hook_init의 조건은 user_is_anonymous()로 로그인 상태를 취한 다음 'user'의 첫 번째 쿼리 인수로 취할 수 있습니다.

<?php 
/** 
* Implements hook_init(). 
*/ 
function mycustommodule_init() { 
    // if 1st argument is user, and they are not logged in, send them away 
    if (user_is_anonymous() && arg(0) == 'user') { 
    drupal_goto('http://example.com/login'); 
    } 
} 

당신이 PHP와 무대 뒤에서 인증 할 수 있다면, 당신은 또한 '로그인'작동을 hook_user 사용하여 로그인이 seemless 만들 수 있습니다.

+0

감사합니다. 덕분에 감사합니다. – PHLAK

1

rules 모듈과 actionstriggers 구성의 조합을 사용할 수 있습니다.

사용자가 페이지/사용자이고 x에 리디렉션 된 상태로 로그인하지 않은 경우.

1

외부 인증을 구현하는 모듈의 예로는 openid.modulehttp_auth_ext.module을들 수 있습니다.
OpenID는 user_external_load()을 사용하며, 아마도 user_external_login_register()을 사용해야합니다.
외부 HTTP 인증은 hook_init()을 사용합니다.

function http_auth_ext_init() { 
    global $user; 
    // Call authentication on any page if it has not been already completed 
    if (! $user->uid && ! $_COOKIE['http_auth_ext_complete']) { 
    http_auth_ext_login($_SERVER['REMOTE_USER']); 
    } 
} 
관련 문제