Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Ok, I checked into user meta data.
    The nftlogin_contract_address was stuck on board apes address.
    I deleted it and resaved the new address but had to deactivate and reactivate the plugin before the new metadata showed up.

    Also, $user_meta[nftlogin_address] doesn’t exist in the record at all(not even null).

    Therefore, line 136 of class-nft-login-public.php below returns the error.

    if (!$addressMatch || !$contractMatch) {
    $user = new WP_Error( ‘authentication_failed’, __( ‘ERROR: Verified NFT does not match registered user.’ ) );
    return $user;
    }

    Warning: Undefined array key “nftlogin_address” in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php on line 134

    Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php on line 134
    Powered by WordPress

    It seems that the plugin can check accurately if the NFT is not in the members wallet.
    But, when trying to log in and the NFT is in the wallet I get this error:

    ERROR: Verified NFT does not match registered user.

    The error displays above the login box. The error appears when logging in, not registering. There is also no visual indication that Metamask is connecting in this case.

    ———————————-
    When registering for the first time with the NFT in the connected wallet the error below appears:

    Error: Please verify nft ownership

    ————————————–
    The following errors also display in the JavaScript console when trying to register, although there are no console errors when trying to login.

    MetaMask - RPC Error: Internal JSON-RPC error. {code: -32603, message: 'Internal JSON-RPC error.', data: {…}}
    (anonymous) @ inpage.js:1
    (anonymous) @ inpage.js:17
    _runReturnHandlers @ inpage.js:17
    _processRequest @ inpage.js:17
    await in _processRequest (async)
    _handle @ inpage.js:17
    handle @ inpage.js:17
    _rpcRequest @ inpage.js:1
    (anonymous) @ inpage.js:1
    request @ inpage.js:1
    bound bound request @ web3-1.6.1.min.js?ver=1.6.1:22
    u.send @ web3-1.6.1.min.js?ver=1.6.1:22
    s @ web3-1.6.1.min.js?ver=1.6.1:10
    n @ web3-1.6.1.min.js?ver=1.6.1:10
    y._executeMethod @ web3-1.6.1.min.js?ver=1.6.1:22
    (anonymous) @ nft-login-module.js?ver=1.2.2:148
    Promise.then (async)
    (anonymous) @ nft-login-module.js?ver=1.2.2:145
    Promise.then (async)
    nftlogin_connect_and_verify @ nft-login-module.js?ver=1.2.2:143
    await in nftlogin_connect_and_verify (async)
    onclick @ wp-login.php?action=register:34

    and

    Uncaught (in promise) Error: Internal JSON-RPC error.
    {
      "code": -32000,
      "message": "execution reverted"
    }
        at Object._fireError (web3-1.6.1.min.js?ver=1.6.1:9:16455)
        at o (web3-1.6.1.min.js?ver=1.6.1:10:26759)
        at a (web3-1.6.1.min.js?ver=1.6.1:22:108629)
        at T (web3-1.6.1.min.js?ver=1.6.1:22:107559)
        at b.run (web3-1.6.1.min.js?ver=1.6.1:9:2055)
        at p (web3-1.6.1.min.js?ver=1.6.1:9:1549)

    I’m waiting for matic to transfer into my wallet so I can mint an nft.
    I added your contract address and put the name Infinity.
    It seems like it should work, it saved the settings with no errors and if I try to log in it says ‘connected address does not own token’ – as expectd.

    It works perfectly now. Awesome!

    I tried changing the $isAdministrator line to:

    $isAdministrator = array();
    $roles = array('administrator');
    $user = wp_get_current_user();
    foreach ($roles as $role){
      if ( in_array( $role, (array) $user->roles ) ) {
         $isAdministrator = in_array('administrator', $user->roles);
      }
    }

    It doesn’t block the login page but still won’t allow admin to login without verifying NFT ownership. (I actually like this better anyway)

    The question is, how can you check if the user is administrator if they aren’t logged in yet?

    Ok, sorry for all the updates.
    I commented out $isAdministrator line 115 from class-nft-login-public.php

    public function authenticate( $user, $username, $password) {

    //$isAdministrator = in_array(‘administrator’, $user->roles);

    Now the login page loads and it looks like it might work but you can’t login as administrator.

    I think something about that line needs to updated. I can’t find the link but something about PHP8 doesn’t allow for unsafe return values.

    Anyway, I think this may allow the plugin to function partially.
    Keep in mind I’m trying these things on a completely blank WordPress site that I don’t care about destroying. And, I might be causing security issues. I’m just messing around with the code without really knowing how it works.

    I’m getting closer now.
    The NFT_Login_Admin class starting on line 22 of class-nft-login-admin.php does not have a nft_login_setting_configuration_cb callback function defined, so I added to it:

    public function nft_login_setting_configuration_cb( $arg ) {
    		    // echo section intro text here
    		    echo '<p>id: ' . $arg['id'] . '</p>';             // id: eg_setting_section
    		    echo '<p>title: ' . $arg['title'] . '</p>';       // title: Example settings section in reading
    		}

    Now, within the plugin admin settings screen I get the output of ‘id’ and ‘title’ and a checkbox for enabling the nft login appears.(that’s progress)

    But, when going to the login screen I get the following error:

    Warning: Undefined property: WP_Error::$roles in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php on line 117
    
    Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php:117 Stack trace: #0 /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php(117): in_array() #1 /var/www/html/wp-includes/class-wp-hook.php(307): Nft_Login_Public->authenticate() #2 /var/www/html/wp-includes/plugin.php(189): WP_Hook->apply_filters() #3 /var/www/html/wp-includes/pluggable.php(608): apply_filters() #4 /var/www/html/wp-includes/user.php(95): wp_authenticate() #5 /var/www/html/wp-login.php(1211): wp_signon() #6 {main} thrown in /var/www/html/wp-content/plugins/nft-login/public/class-nft-login-public.php on line 117

    So, I think the callback has to be properly defined for this to work.

    This isn’t the answer, but so far I removed lines 184-190 from class-nft-login-admin.php

    // Configuration section
          //  add_settings_section(
          //      $this->option_name. '_configuration',
          //      __( 'Plugin Configuration', 'nft-login' ),
        //        array( $this, $this->option_name . '_configuration_cb' ),
        //        $this->plugin_name
      //      );

    There is no more error, but I don’t see any indication that the plugin is functioning.

    I get the same exact error regarding “nft_login_setting_configuration_cb” on line 1694 of template.php

    I’ve tried every version of your plugin as a test.
    V1.0 does not produce this error but a different error prevents wp-login from loading completely.

    I’d like to use polygon so 1.2.0 will be good for me if we can get this callback to act nice.

    I wonder what configuration works? I have disabled every other plugin and using wordpress 5.9.2 and tried both 2021 and 2022 themes.

Viewing 9 replies - 1 through 9 (of 9 total)