Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange output for a php request of $_SESSION #4774

Closed
1 task done
Antoviscomi opened this issue Sep 19, 2024 · 4 comments
Closed
1 task done

Strange output for a php request of $_SESSION #4774

Antoviscomi opened this issue Sep 19, 2024 · 4 comments
Labels
feedback php Pull requests that update Php code question

Comments

@Antoviscomi
Copy link
Contributor

Antoviscomi commented Sep 19, 2024

When I try to obtain informations on active LWC(PHP) session in my machine by

session_start(); echo '<pre>'; print_r($_SESSION); echo '</pre>';

I receive this response caused by a request that throws an error about an incomplete object in the PHP session:

`(
    [JX_LANG] => it_IT
    [JELIX_USER] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => cDaoRecord_lizmap_Jx_user_Jx_pgsql
            [__dao_profile:protected] => jauth
            [login] => admin
            [email] => [email protected]
            [password] => $2y$10$kHglBdPNhE8gwddEewV.YOXJZQJbT9YhzdR254rAqcCWFUMpIN2g2
            [firstname] => 
            [lastname] => 
            [organization] => 
            [phonenumber] => 
            [street] => 
            [postcode] => 
            [city] => 
            [country] => 
            [comment] => 
            [status] => 1
            [keyactivate] => 
            [request_date] => 
            [create_date] => 2023-07-18 09:51:11.441193
        )

    [JFORMS_SESSION] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => jFormsSession
        )

)`

then I'm not able to pass $_SESSION info to another php because of session crash.
can someone tell me if is it a bug or a misconfiguration caused by me?
And in both cases what can i do?

Versions, safeguards, check summary etc

Versions :

  • Lizmap Web Client : 3.7.10
  • Lizmap plugin : 4.4.0
  • QGIS Desktop : 3.38.3
  • QGIS Server : 3.38.3
  • Py-QGIS-Server : not used
  • QGIS Server plugin atlasprint : 3.4.1
  • QGIS Server plugin lizmap_server : 2.10.0
  • QGIS Server plugin wfsOutputExtension : 1.8.2
List of safeguards :
  • Mode : normal
  • Allow parent folder : yes
  • Number of parent : 10 folder(s)
  • Prevent other drive : no
  • Prevent PG service : no
  • Prevent PG Auth DB : no
  • Force PG user&pass : no
  • Prevent ECW : no

Check Lizmap plugin

  • I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

Operating system

Ubuntu 22.04

Browsers

Chrome

Browsers version

Versione 129.0.6668.58 (Build ufficiale) (a 64 bit)

Relevant log output

No response

@nworr
Copy link
Contributor

nworr commented Sep 20, 2024

According to stack overflow, it's because the "cDaoRecord_lizmap_Jx_user_Jx_pgsql" (and jFormsSession) classes are unknown when session is deserialized (by print_r)

If you want to know the currrent user in session, you need to use jelix/lizmap objects ( jAuth::getUserSession()) or ensure the class used by object in session are defined.

@Gustry Gustry added feedback php Pull requests that update Php code labels Sep 20, 2024
@Antoviscomi
Copy link
Contributor Author

Antoviscomi commented Sep 20, 2024

@nworr

If you want to know the currrent user in session, you need to use jelix/lizmap objects ( jAuth::getUserSession()) or ensure the class used by object in session are defined.

using jAuth::getUserSession() as follow:

try {
    // Prova a ottenere la sessione utente
    $user = jAuth::getUserSession();

    if ($user && !($user instanceof jAuthDummyUser)) {
        // Controlla che l'utente abbia le proprietà id e group
        $userId = isset($user->id) ? $user->id : 'N/A';
        $group = isset($user->group) ? $user->group : 'N/A';
        error_log("Debug: Utente connesso. ID: $userId, Gruppo: $group");

        // Verifica se l'utente è admin o registrato
        if (in_array($group, ['admins', 'users'])) {
            error_log("Debug: Utente autorizzato.");
            // Includi il form HTML o reindirizza alla pagina protetta
            // include '/var/www/webgism/lizmap/www/mapsm/myscript.php';
            exit;
        } else {
            error_log("Debug: Utente non autorizzato." . print_r($user, true));
        }
    } else {
        error_log("Debug: Utente non autenticato o autenticazione fallita.");
    }
} catch (Exception $e) {
    error_log("Debug: Errore durante il recupero della sessione utente: " . $e->getMessage());
}

my debug log come out as you can see after successful login in LWC

PHP message: Debug: Utente connesso. ID: , Gruppo: ', referer: http://xxx.xx.xx.xx/webgism/admin.php/auth/login?auth_url_return=%2Fwebgism%2Fmapsm%2Fmyscript.php

@nworr
Copy link
Contributor

nworr commented Sep 27, 2024

the ACL groups to which the user belongs can be found with \jAcl2DbUserGroup::getGroups();

@Antoviscomi
Copy link
Contributor Author

@nworr my mistake! The php session path was not readable to the system group, so the signal returned by jAuth::getUserSession() was null!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback php Pull requests that update Php code question
Projects
None yet
Development

No branches or pull requests

3 participants