auth.php 程式修改

  1. 認證程式 auth.php 中 jquery() 函式在 moodle 2.3 版中沒有,所以註解掉,直接在 signup_form.php 加入登入按鈕。
    [root@dywang mod_tmp]# diff -uNwB elcentra/auth.php ../auth/elcentra/auth.php 
    --- elcentra/auth.php	2014-04-21 19:32:06.000000000 +0800
    +++ ../auth/elcentra/auth.php	2019-03-06 10:36:36.185681157 +0800
    @@ -226,7 +226,7 @@
             global $PAGE, $OUTPUT, $CFG;
             $conf = get_config("auth/elcentra", "add_code_mode");
             if ($conf == "auto") {
    -            $PAGE->requires->jquery();
    +            //$PAGE->requires->jquery();
                 $PAGE->requires->js_init_code("buttonsAddMethod = 'auto';");
                 $content = str_replace(array("\n", "\r"), array("\\\n", "\\\r",), $this->get_buttons_string());
                 $PAGE->requires->js_init_code("buttonsCode = '$content';");
    
  2. login/index_form.html 的「忘記密碼連結」上方加上 Facebook 及 Google 認證登入按鈕。
    [root@dywang login]# vim index_form.html 
        <center>
    <div class="moreproviderlink">
    <a href="<?php echo $CFG->httpswwwroot; ?>/auth/elcentra/google_request.php">
    <img src="<?php echo $CFG->httpswwwroot; ?>/auth/elcentra/img/google.png"></a>
    <a href="<?php echo $CFG->httpswwwroot; ?>/auth/elcentra/facebook_request.php">
    <img src="<?php echo $CFG->httpswwwroot; ?>/auth/elcentra/img/facebook.png"></a> <br>
    </div>
            <div class="forgetpass"><a href="forgot_password.php">
    <?php print_string("forgotten") ?></a></div>
    

    Image moodleelcentralogin
  3. 認證 auth.php 程式判斷登入的社群帳號的 verified 參數是否存在?也就是其 email 是否確認有效?但實際測試 facebook 已確認的 email,並沒有回傳 verified,所以改成只要有從 facebook 取得 email 就接受。
    @@ -243,7 +243,7 @@
    		list($username, $email, $firstName, $lastName, $country, $city, $timezone, $verified) = $details;
    		
    		//throw an error if the email address is not verified
    -		if (!$verified) {
    +		if (!$email) {
    			throw new moodle_exception('emailaddressmustbeverified', 'auth_elcentra');
    		}