Parcourir la source

Bumped version to 0.0.67

Jannick Knudsen il y a 4 ans
Parent
commit
e490c6aebb
6 fichiers modifiés avec 27 ajouts et 4 suppressions
  1. 1 1
      VERSION
  2. 1 0
      VERSIONLOG
  3. 1 1
      package.json
  4. 9 0
      plug_login.php
  5. 13 0
      plug_prometheus.php
  6. 2 2
      plugin.php

+ 1 - 1
VERSION

@@ -1 +1 @@
-v0.0.66
+v0.0.67

+ 1 - 0
VERSIONLOG

@@ -65,3 +65,4 @@ v0.0.63
 v0.0.64
 v0.0.65
 v0.0.66
+v0.0.67

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dagsplug",
-  "version": "0.0.66",
+  "version": "0.0.67",
   "description": "",
   "main": "script_backend.js",
   "scripts": {

+ 9 - 0
plug_login.php

@@ -316,10 +316,19 @@ body {
 		function plugin_user_register($id) {
 			$user_info = get_userdata($id);
 
+			if (empty($_POST['r_proselect'])) {
+				$_POST['r_proselect'] = "Perspektiv";
+			}
 			update_user_meta($id, 'Proselect', $_POST['r_proselect']);
 
+			if (empty($_POST['r_navn'])) {
+				$_POST['r_navn'] = "ingen";
+			}
 			update_user_meta($id, 'Navn', $_POST['r_navn']);
 
+			if (empty($_POST['r_membership'])) {
+				$_POST['r_membership'] = "ingen";
+			}
 			update_user_meta($id, 'Gruppe', $_POST['r_membership']);
 
 			//   update_usermeta($id, 'Institution'	, $_POST['r_institution'] );

+ 13 - 0
plug_prometheus.php

@@ -23,6 +23,18 @@ if (!class_exists("plug_prometheus")) {
 				));
 			});
 
+			add_filter('rest_authentication_errors', function ($result) {
+				if (!empty($result)) {
+					return $result;
+				}
+
+				if (!(is_user_logged_in() && (current_user_can('edit_posts'))) && !($_SERVER['REQUEST_URI'] == "/wp-json/metrics")) {
+
+					return new WP_Error('rest_not_allowed', 'Morten - is that you? - You are not allowed here ;)', array('status' => 401));
+				}
+				return $result;
+			});
+
 		}
 		function help() {
 			?>
@@ -46,6 +58,7 @@ if (!class_exists("plug_prometheus")) {
 			// the default JSON response will be handled automatically by WP-API
 			if ($request->get_route() == "/metrics") {
 				header('Content-Type: text/plain; charset=' . get_option('blog_charset'));
+				http_response_code(200);
 				$metrics = $this->get_wordpress_metrics();
 				echo $metrics;
 				$served = true; // tells the WP-API that we sent the response already

+ 2 - 2
plugin.php

@@ -4,7 +4,7 @@ Plugin Name: dagsopt
 Plugin URI: https://git.tum.dk/tum.dk/dagsplug/
 Description: Tools
 Author: iskedk
-Version: 0.0.66
+Version: 0.0.67
 Date: 2021-01-14
 Author URI: https://iske.dk/
 Text Domain: dagsopt
@@ -17,7 +17,7 @@ function wppluginspage() {
 $wp_dagsopt = new dagsopt();
 
 class dagsopt {
-	var $version = "0.0.66";
+	var $version = "0.0.67";
 	var $publish_date = "2021-01-14";
 	var $pluginname;
 	var $plugintitle;