Beispiel #1
0
         if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
             $json_output["errors"][] = "Error setting user secret string.";
         }
         if (!send_password_change_confirmation_email($user)) {
             $json_output["errors"][] = "Error sending password change confirmation email.";
         }
     } else {
         if (send_password_change_info($user)) {
             $json_output["forgot_password"] = true;
         } else {
             $json_output["errors"][] = "Error sending password change confirmation email.";
         }
     }
 } else {
     $authmethod = $user->auth;
     if (is_internal_auth($authmethod) or !empty($CFG->{'auth_' . $authmethod . '_stdchangepassword'})) {
         // handle internal authentication
         // set 'secret' string
         $user->secret = random_string(15);
         if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
             $json_output["errors"][] = "Error setting user secret string.";
         }
         // send email (make sure mail block is off)
         $user->mailstop = 0;
         if (@send_password_change_confirmation_email($user)) {
             $json_output["forgot_password"] = true;
         } else {
             $json_output["errors"][] = "Error sending password change confirmation email.";
         }
     } else {
         $json_output["errors"][] = "This server does not support mPage's password recovery.";
Beispiel #2
0
 * Login code adapted from:
 * moodle/login/index.php
 * Moodle functions get_record (datalib.php) and 
 * get_complete_user_record (lib/moodlelib.php) when passed 'user' or 'username' 
 ******************************************************************************/
$user_id = $moodle_user_id;
if ($user = get_record('user', 'id', $user_id)) {
    //	print "<hr>logging into Moodle...";
    $user = get_complete_user_data('username', $user->username);
    $USER = $user;
    add_to_log(SITEID, 'user', 'login', "view.php?id={$USER->id}&course=" . SITEID, $USER->id, 0, $USER->id);
    update_user_login_times();
    set_moodle_cookie($USER->username);
    set_login_session_preferences();
    //Select password change url
    if (is_internal_auth($USER->auth) || $CFG->{'auth_' . $USER->auth . '_stdchangepassword'}) {
        $passwordchangeurl = $CFG->wwwroot . '/login/change_password.php';
    } elseif ($CFG->changepassword) {
        $passwordchangeurl = $CFG->changepassword;
    } else {
        $passwordchangeurl = '';
    }
    // check whether the user should be changing password
    if (get_user_preferences('auth_forcepasswordchange', false) || $frm->password == 'changeme') {
        if ($passwordchangeurl != '') {
            redirect($passwordchangeurl);
        } else {
            error("You cannot proceed without changing your password. \n\t\t\t\t   However there is no available page for changing it.\n\t\t\t\t   Please contact your Moodle Administrator.");
        }
    }
    /// Prepare redirection