Ver código fonte

Maj redirection QRCode

stany.ferer 1 ano atrás
pai
commit
864d04f01d

+ 1 - 1
core/json/events.check-control-emargement.php

@@ -2,7 +2,7 @@
 
 if (session::isConnect("salarie")) {
     $return = array();
-    if (event::checkUrl(core::getPost("qRcode")) != DOMAIN_EVENTS and event::checkUrl(core::getPost("qRcode")) != DOMAIN_CONTROL and PWA == 0) {
+    if (event::checkUrl(core::getPost("qRcode")) != DOMAIN_EVENTS and event::checkUrl(core::getPost("qRcode")) != DOMAIN_CONTROL) {
         $return["result"] = false;
         $return["description"] = "Le QR-Code n'est pas valide";
         $return["salarie"] = null;

+ 12 - 26
public-events/js/list-events.js

@@ -121,30 +121,18 @@ $("#qrr-close").on("click", function () {
 });
 
 function checkEmagementSalarie(){
-    var formData = {
-        form: $("#emargementControlFrom").val(),
-        event: $("#form-event").val(),
-        qRcode: $("#QRCodeRead").val(),
-    };
-
     if (checkconnection()) {
-
-        $.ajax({
-            type: "POST",
-            url: "json.php?jsonData=check-control-emargement",
-            data: formData,
-            dataType: "json",
-            encode: true,
-        }).done(function (data) {
-            $('#ResultQRCode').remove();
-            $("#confirmationModal").append(getConfirmModal(data));
-            $('#ResultQRCode').modal("show");
-            if (data["result"] == true) {
-                $('#ResultQRCode').on('hidden.bs.modal', function () {
-                    getEvements();
-                });
-            }
-        }).fail(function () {
+        const currentUrl = window.location;
+        const targetUrl = new URL($("#QRCodeRead").val());
+
+        // Vérifiez si les deux URLs sont du même domaine
+        if (currentUrl.protocol === targetUrl.protocol &&
+            currentUrl.hostname === targetUrl.hostname &&
+            currentUrl.port === targetUrl.port) {
+            
+            // Redirigez vers l'URL cible
+            window.location.replace(targetUrl.href);
+        } else {
             retour = Array;
             retour["result"] = false;
             retour["description"] = "Le QR-Code n'est pas valide";
@@ -154,9 +142,7 @@ function checkEmagementSalarie(){
             $('#ResultQRCode').remove();
             $("#confirmationModal").append(getConfirmModal(retour));
             $('#ResultQRCode').modal("show");
-        });
-        $("#QRCodeRead").removeAttr('value');
-
+        }
     } else {
         $("#divOffline").empty();
         $("#divOffline").append('<div class="alert alert-warning" role="alert">Vous n\'êtes pas connecté à internet</div>');