之前很少看到有關討論 LifeType 登入認證的文章!今天看到一篇文章真是很棒!
引用文章自 Hami 網誌
http://plog.tcc.edu.tw/post/3/1147
pLog 是個優秀的軟體,採用 MVC 設計理念,讓網頁展現的部份可以獨立出來,符合了 BLog 個人化的特性,plugin 的功能使得 BLog 附加的功能具彈性容易擴展。
但如要對特定 user 申請限制時,目前並沒有可用的方式,因此我自已修改了 pLog 認證的程式,可以讓申請者和台中縣網既有的 LDAP 帳號做整合。
1.修改 class/dao/users.class.php
這個部份為登入時認證,必須是單位的使用者才可進入。
function authenticateUser( $user, $pass )
{
// 呼叫自訂的認證函式
if(!$this->tcc_ldap_check($user,$pass))
return false;
....
// 自訂的認證函式
function tcc_ldap_check($user,$pass){
$check_result = false;
// 判斷是否為單位的使用者
......
return $check_result;
}
2. 修改 class/summary/action/dousercreation.class.php
這個部份是註冊時的檢查,只有單位的使用者才可申請。
.....
function perform()
{
// if all data is correct, then we can proceed and use it
$tf = new Textfilter();
$this->userName = $tf->filterAllHTML($this->_request->getValue( "userName" ));
....
$this->_view = new SummaryView( "registerstep1" );
$this->_view->setErrorMessage( $this->_locale->tr("error_passwords_dont_match");
$this->_form->setFieldValidationStatus( "userPasswordCheck", false ) ;
$this->setCommonData( true );
return false;
}
//檢查是否為台中縣教職員
if (!$users->tcc_ldap_check($this->userName,$this->userPassword)){
$this->_view->setErrorMessage('抱歉! 本網誌謹限台中縣教職員申請!');
$this->_form->setFieldValidationStatus( "userName", false );
$this->setCommonData( true );
return false;
}
// if everything went fine, then proceed
$this->_view = new doBlogRegistrationView();
$this->setValues();
$this->setCommonData();
return true;
}
}