Permalink
Browse files

Fixed logic error.

Now also first time users can be course creators.
  • Loading branch information...
1 parent a2631c9 commit e582b65e30d10f304588cb28103338e8b3e073f1 paca70 committed Mar 14, 2003
Showing with 24 additions and 25 deletions.
  1. +24 −25 lib/moodlelib.php
View
@@ -538,37 +538,36 @@ function authenticate_user_login($username, $password) {
if (auth_user_login($username, $password)) { // Successful authentication
if ($user = get_user_info_from_db("username", $username)) {
-
- if (function_exists('auth_iscreator')) { // Check if the user is a creator
- if (auth_iscreator($username)) {
- if (! record_exists("user_coursecreators", "userid", $user->id)) {
- $cdata['userid']=$user->id;
- $creator = insert_record("user_coursecreators",$cdata);
- if (! $creator) {
- error("Cannot add user to course creators.");
- }
- }
- } else {
- if ( record_exists("user_coursecreators", "userid", $user->id)) {
- $creator = delete_record("user_coursecreators", "userid", $user->id);
- if (! $creator) {
- error("Cannot remove user from course creators.");
- }
- }
- }
- }
-
if ($md5password <> $user->password) { // Update local copy of password for reference
set_field("user", "password", $md5password, "username", $username);
}
- return $user;
-
} else {
- return create_user_record($username, $password);
+ $user = create_user_record($username, $password);
}
- }
- return false;
+ if (function_exists('auth_iscreator')) { // Check if the user is a creator
+ if (auth_iscreator($username)) {
+ if (! record_exists("user_coursecreators", "userid", $user->id)) {
+ $cdata['userid']=$user->id;
+ $creator = insert_record("user_coursecreators",$cdata);
+ if (! $creator) {
+ error("Cannot add user to course creators.");
+ }
+ }
+ } else {
+ if ( record_exists("user_coursecreators", "userid", $user->id)) {
+ $creator = delete_record("user_coursecreators", "userid", $user->id);
+ if (! $creator) {
+ error("Cannot remove user from course creators.");
+ }
+ }
+ }
+ }
+
+ return $user;
+ } else {
+ return false;
+ }
}

0 comments on commit e582b65

Please sign in to comment.