function editUser($params) { if (empty($params['uid']) || empty($params['userid']) || !isset($params['active']) || empty($params['type'])) { return array('status' => 'missing_param'); } if (!$params['__superuser']) { echo json_encode(array('status' => 'permission_denied')); exit; } $janus_config = sspmod_janus_DiContainer::getInstance()->getConfig(); $uid = $params['uid']; $user = new sspmod_janus_User(); $user->setUid($uid); $user->load(sspmod_janus_User::UID_LOAD); $user->setActive($params['active']); $user->setUserid($params['userid']); $user->setType($params['type']); $user->save(); return array('uid' => $uid); }
exit; } $attributes = $as->getAttributes(); // Require that we can get this users id. if (!isset($attributes[$userIdAttribute])) { throw new Exception('User ID is missing'); } /** @var string $userId */ $userId = $attributes[$userIdAttribute][0]; if (isset($_POST['submit'])) { $csrf_provider = sspmod_janus_DiContainer::getInstance()->getCsrfProvider(); if (!isset($_POST['csrf_token']) || !$csrf_provider->isCsrfTokenValid('add_user', $_POST['csrf_token'])) { SimpleSAML_Logger::warning('Janus: [SECURITY] CSRF token not found or invalid'); throw new SimpleSAML_Error_BadRequest('Missing valid csrf token!'); } // Create the user $user = new sspmod_janus_User($janusConfig->getValue('store')); $user->setUserid($userId); $user->setType($defaultUserType); $user->setActive('yes'); $user->save(); // Trigger an event $pm = new sspmod_janus_Postman(); $pm->post('New user created', 'A new user has been created with username: '******'USER-NEW', $user->getUid()); } $template = new SimpleSAML_XHTML_Template($sspConfig, 'janus:newuser.php', 'janus:newuser'); $template->data['userid'] = $userId; if (isset($user)) { $template->data['user_created'] = TRUE; } $template->show();
$check_user = new sspmod_janus_User($janus_config->getValue('store')); $check_user->setUserid($_POST['userid']); if ($check_user->load(sspmod_janus_User::USERID_LOAD) != FALSE) { $msg = 'error_user_already_exists'; } else { $new_user = new sspmod_janus_User($janus_config->getValue('store')); $new_user->setUserid($_POST['userid']); $new_user->setType($_POST['type']); if (isset($_POST['active']) && $_POST['active'] == 'on') { $active = 'yes'; } else { $active = 'no'; } $new_user->setActive($active); $new_user->setData($_POST['userdata']); if (!$new_user->save()) { $msg = 'error_user_not_created'; } else { SimpleSAML_Utilities::redirect(SimpleSAML_Utilities::selfURLNoQuery(), array('selectedtab' => $selectedtab)); } } } } if (isset($_POST['submit'])) { if (!empty($_POST['entityid'])) { if (check_uri($_POST['entityid'])) { if (!isset($_POST['entityid']) || empty($_POST['entitytype'])) { $msg = 'error_no_type'; $old_entityid = $_POST['entityid']; $old_entitytype = $_POST['entitytype']; } else {
function editUser($params) { if (empty($params['uid']) || empty($params['userid']) || !isset($params['active']) || empty($params['type'])) { return array('status' => 'missing_param'); } $janus_config = SimpleSAML_Configuration::getConfig('module_janus.php'); $uid = $params['uid']; $user = new sspmod_janus_User($janus_config->getValue('store')); $user->setUid($uid); $user->load(sspmod_janus_User::UID_LOAD); $user->setActive($params['active']); $user->setUserid($params['userid']); $user->setType($params['type']); $user->save(); return array('uid' => $uid); }