Example #1
0
 function send_password()
 {
     $user_id = Request::param('id');
     if (!current_user()->is('admin')) {
         Response()->not_authorized();
     }
     if (!isset($user_id)) {
         Response('Invalid user id');
     }
     $user = new User($user_id);
     $result = $user->send_password();
     if ($user->validation_passed()) {
         Response($result);
     } else {
         Response()->error($user->errors());
     }
 }
Example #2
0
            }
        }
    }
}
// Change password with a new generated one
if (($action == 'confirm_password' && $confirm == 'yes' || $action == 'confirm_passwordsend' && $confirm == 'yes') && $caneditpassword) {
    $edituser = new User($db);
    $edituser->fetch($id);
    $newpassword = $edituser->setPassword($user, '');
    if ($newpassword < 0) {
        // Echec
        $message = '<div class="error">' . $langs->trans("ErrorFailedToSetNewPassword") . '</div>';
    } else {
        // Succes
        if ($action == 'confirm_passwordsend' && $confirm == 'yes') {
            if ($edituser->send_password($user, $newpassword) > 0) {
                $message = '<div class="ok">' . $langs->trans("PasswordChangedAndSentTo", $edituser->email) . '</div>';
                //$message.=$newpassword;
            } else {
                $message = '<div class="ok">' . $langs->trans("PasswordChangedTo", $newpassword) . '</div>';
                $message .= '<div class="error">' . $edituser->error . '</div>';
            }
        } else {
            $message = '<div class="ok">' . $langs->trans("PasswordChangedTo", $newpassword) . '</div>';
        }
    }
}
// Action initialisation donnees depuis record LDAP
if ($_POST["action"] == 'adduserldap') {
    $selecteduser = $_POST['users'];
    $required_fields = array($conf->global->LDAP_FIELD_NAME, $conf->global->LDAP_FIELD_FIRSTNAME, $conf->global->LDAP_FIELD_LOGIN, $conf->global->LDAP_FIELD_LOGIN_SAMBA, $conf->global->LDAP_FIELD_PASSWORD, $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, $conf->global->LDAP_FIELD_PHONE, $conf->global->LDAP_FIELD_FAX, $conf->global->LDAP_FIELD_MOBILE, $conf->global->LDAP_FIELD_MAIL, $conf->global->LDAP_FIELD_SID);