Skip to content

Instantly share code, notes, and snippets.

@sunner
Created April 8, 2011 00:03
Show Gist options
  • Save sunner/909040 to your computer and use it in GitHub Desktop.
Save sunner/909040 to your computer and use it in GitHub Desktop.
Before creating cas auth accounts in moodle directly, show some information to users and ask for their confirmation.
Index: moodlelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v
retrieving revision 1.960.2.168
diff -p -r1.960.2.168 moodlelib.php
*** moodlelib.php 23 Feb 2011 20:23:52 -0000 1.960.2.168
--- moodlelib.php 8 Apr 2011 00:05:59 -0000
*************** function authenticate_user_login($userna
*** 3226,3231 ****
--- 3242,3255 ----
$user = update_user_record($username, get_auth_plugin($user->auth));
}
} else {
+ $cas_create_new = optional_param('createnewcas', 0, PARAM_BOOL);
+ if (!$cas_create_new) {
+ echo '<p>这是您第一次通过CAS认证访问乐学网。</p>';
+ echo '<p>如果您在乐学网已经有账号,务必先<a href="/bind_cas_users">绑定CAS和本站旧账号</a>,否则已有个人数据(选课、成绩、作业等)都会丢失。此操作只需一次。</p>';
+ echo '<p>如果您是乐学网的新用户,可以直接建立新账号。</p>';
+ echo '<p><a href="/bind_cas_users">我是老用户,要做绑定</a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="?createnewcas=1">我是新用户,建新账号</a></p>';
+ die;
+ }
// if user not found, create him
$user = create_user_record($username, $password, $auth);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment