Jump to content
thirty bees forum
  • 0

oneall.com Module


AndyC

Question

Please could I have a bit of help here .. I have used this module for as long as I can remember.. It's been on the back burner for while now and am finally getting around to look into it.

I already have Facebook log in working correctly and logs me in fine.But it is not the case with Twitter, Everything works fine except when it comes to redirecting but to my page I get the error message below with a 500 page.

Now being nosy I read into on line 161 expect a 1, so I went there and found Tools::redirect ( ); so I tried making it (1 ); .. It got me past the 500 page but to a not found product page and it hadn't signed me in either.

So am hoping someone here can help if at all possible

 

Decoded exception

Too few arguments to function ToolsCore::redirect(), 0 passed in /home/edit out/public_html/modules/oneallsociallogin/controllers/front/register.php on line 161 and at least 1 expected

in file classes/Tools.php at line 218

Source file: classes/Tools.php

199:            }
200:
201:            $result .= sha1($entropy, true);
202:        }
203:
204:        return substr($result, 0, $length);
205:    }
206:
207:    /**
208:     * Redirect user to another page
209:     *
210:     * @param string       $url     Desired URL
211:     * @param string       $baseUri Base URI (optional)
212:     * @param Link         $link
213:     * @param string|array $headers A list of headers to send before redirection
214:     *
215:     * @since   1.0.0
216:     * @version 1.0.0 Initial version
217:     */
218:    public static function redirect($url, $baseUri = __PS_BASE_URI__, Link $link = null, $headers = null)
219:    {
220:        if (!$link) {
221:            $link = Context::getContext()->link;
222:        }
223:
224:        if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link) {
225:            if (strpos($url, $baseUri) === 0) {
226:                $url = substr($url, strlen($baseUri));
227:            }
228:            if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) {

 

Thanks

Link to comment
Share on other sites

Recommended Posts

  • 0

You upgraded PHP recently, didn't you?

Tools::redirect() needs al least one argument, the address to redirect to. Module code apparently doesn't deliver that, so it's a bit unclear how this could ever work before.

Anyways, point of malfunction isn't in the cited code (Tools.php), but in the module in register.php line 161 or earlier.

Link to comment
Share on other sites

  • 0
On 4/20/2020 at 6:17 PM, datakick said:

Your hosting provider changed the php version on your *live site* automatically without your consent? That's just... well I'm speechless. 

It is quite common for the hosting companies especially if all you are "hiring" is a cpanel and space for your website. Had this a few times with various hosts which is why I switched to VPS

Link to comment
Share on other sites

  • 0

Sigh

having issues with oneall again after I got it working with their help 

Does this mean anything to any of you and how to fix.. It only happens with twitter log in , facebook is fine


` Decoded exception
Too few arguments to function ToolsCore::redirect(), 0 passed in /home/username/domains/mywebsite.co.uk/public_html/modules/oneallsociallogin/controllers/front/register.php on line 161 and at least 1 expected
in file classes/Tools.php at line 152
Source file: classes/Tools.php

133: try {
134: return random_bytes($length);
135: } catch (Exception $e) {}
136: }
137:
138: return '';
139: }
140:
141: /**
142: * Redirect user to another page
143: *
144: * @param string $url Desired URL
145: * @param string $baseUri Base URI (optional)
146: * @param Link $link
147: * @param string|array $headers A list of headers to send before redirection
148: *
149: * @since 1.0.0
150: * @version 1.0.0 Initial version
151: */
152: public static function redirect($url, $baseUri = PS_BASE_URI, Link $link = null, $headers = null)
153: {
154: if (!$link) {
155: $link = Context::getContext()->link;
156: }
157:
158: if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link) {
159: if (strpos($url, $baseUri) === 0) {
160: $url = substr($url, strlen($baseUri));
161: }
162: if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) {

Stack trace
1. modules/oneallsociallogin/controllers/front/register.php:161 source ToolsCore::redirect()
2. classes/controller/Controller.php:208 source OneAllSocialLoginRegisterModuleFrontController->initContent()
3. classes/controller/FrontController.php:255 source ControllerCore->run()
4. classes/Dispatcher.php:852 source FrontControllerCore->run()
5. ./index.php:33 source DispatcherCore->dispatch()

`

 

 

 

Link to comment
Share on other sites

  • 0
30 minutes ago, AndyC said:

I know , I thought it was exactly the same. I haven't changed anything on my website to cause it. I even reinstalled their corrected version from github.

Have you any idea as to what is causing the error

Well, obviously the 'corrected' version is not fixed :)

Could you please share github repo, I'll have a look

Link to comment
Share on other sites

  • 0
class OneAllSocialLoginRegisterModuleFrontController extends ModuleFrontController
{
    public $auth = false;
    public $ssl = true;

    /**
     * Assign template vars related to page content
     */
    public function initContent()
    {
        parent::initContent();
        global $smarty;

        // Restore back value.
        $back = Tools::getValue('back');

        if (!empty($back))
        {
            $this->context->smarty->assign('back', Tools::safeOutput($back));
        }

        // Did an error occur?
        $have_error = true;

        // The cookie is required to proceed.
        if (isset($this->context->cookie->oasl_data))
        {
            // Extract the data.
            $data = json_decode($this->context->cookie->oasl_data, true);

            // Check data format.
            if (is_array($data))
            {
                $have_error = false;

                // Submit Button Clicked
                if (Tools::isSubmit('submit'))
                {
                    // Reset Errors.
                    $this->errors = array();

                    // Read fields.
                    $email = trim(Tools::getValue('oasl_email'));
                    $firstname = trim(Tools::getValue('oasl_firstname'));
                    $lastname = trim(Tools::getValue('oasl_lastname'));
                    $newsletter = intval(Tools::getValue('oasl_newsletter'));

                    // Make sure the firstname is not empty.
                    if (strlen($firstname) == 0)
                    {
                        $this->errors[] = Tools::displayError('Please enter your first name');
                    }
                    // Make sure the format of the firstname is correct.
                    elseif (!Validate::isName($firstname))
                    {
                        $this->errors[] = Tools::displayError('Please enter a valid first name');
                    }

                    // Make sure the lastname is not empty.
                    if (strlen($lastname) == 0)
                    {
                        $this->errors[] = Tools::displayError('Please enter your lastname');
                    }
                    // Make sure the format of the lastname is correct.
                    elseif (!Validate::isName($lastname))
                    {
                        $this->errors[] = Tools::displayError('Please enter a valid last name');
                    }

                    // Make sure the email address it is not empty.
                    if (strlen($email) == 0)
                    {
                        $this->errors[] = Tools::displayError('Please enter your email address');
                    }
                    // Make sure the format of the email address is correct.
                    elseif (!Validate::isEmail($email))
                    {
                        $this->errors[] = Tools::displayError('Please enter a valid email address');
                    }
                    // Make sure the email address is not already taken.
                    elseif (oneall_social_login_tools::get_id_customer_for_email_address($email) !== false)
                    {
                        $this->errors[] = Tools::displayError('This email address is already taken');
                    }

                    // We are good to go.
                    if (count($this->errors) == 0)
                    {
                        // Store the manually entered email fields.
                        $data['user_email'] = strtolower($email);
                        $data['user_first_name'] = ucwords(strtolower($firstname));
                        $data['user_last_name'] = ucwords(strtolower($lastname));
                        $data['user_newsletter'] = ($newsletter == 1 ? 1 : 0);

                        // Email flags.
                        $send_email_to_admin = ((Configuration::get('OASL_EMAIL_ADMIN_DISABLE') != 1) ? true : false);
                        $send_email_to_customer = ((Configuration::get('OASL_EMAIL_CUSTOMER_DISABLE') != 1) ? true : false);

                        // Create a new account.
                        $id_customer = oneall_social_login_tools::create_customer_from_data($data, $send_email_to_admin, $send_email_to_customer);

                        // Login the customer.
                        if (!empty($id_customer) and oneall_social_login_tools::login_customer($id_customer))
                        {
                            // Remove the data
                            unset($this->context->cookie->oasl_data);

                            // A refresh is required to update the page
                            $back = trim(Tools::getValue('back'));
                            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
                            Tools::redirect($back);
                        }
                    }
                }
                // First call of the page.
                else
                {
                    $smarty->assign('oasl_populate', 1);
                    $smarty->assign('oasl_email', (isset($data['user_email']) ? $data['user_email'] : ''));
                    $smarty->assign('oasl_first_name', (isset($data['user_first_name']) ? $data['user_first_name'] : ''));
                    $smarty->assign('oasl_last_name', (isset($data['user_last_name']) ? $data['user_last_name'] : ''));
                    $smarty->assign('oasl_newsletter', 1);
                }

                // Assign template vars.
                $smarty->assign('identity_provider', $data['identity_provider']);
                $smarty->assign('oasl_register', $this->context->link->getModuleLink('oneallsociallogin', 'register'));

                // Show our template.
                $this->setTemplate('oneallsociallogin_register.tpl');
            }
        }

        // We could not extract the data.
        if ($have_error)
        {
          Tools::redirect();
        }
    }
}

 

Link to comment
Share on other sites

  • 0

@AndyC, you didn't replace the like 161 with the new content. The file should end like this:

 

        // We could not extract the data.
        if ($have_error)
        {
            $back = trim(Tools::getValue('back'));
            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
            Tools::redirect($back);
        }

 

Link to comment
Share on other sites

  • 0

Don't know where my last post went ..

But this is what it looks like now .Am still getting a server error

// Show our template.
                $this->setTemplate('oneallsociallogin_register.tpl');
            }
        }

        // We could not extract the data.
        if ($have_error)
        {
            $back = trim(Tools::getValue('back'));
            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
            Tools::redirect($back);
        }

 

Link to comment
Share on other sites

  • 0
2 minutes ago, AndyC said:

Don't know where my last post went ..

But this is what it looks like now .Am still getting a server error


// Show our template.
                $this->setTemplate('oneallsociallogin_register.tpl');
            }
        }

        // We could not extract the data.
        if ($have_error)
        {
            $back = trim(Tools::getValue('back'));
            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
            Tools::redirect($back);
        }

 

It can't be the same error. Even if the $back variable contain null, it is still value that is being passed to the Tools::redirect method. So it's not possible for this to throw Too few arguments to function error.

Link to comment
Share on other sites

  • 0

OK downloaded the error and decrypted.. But yes it is different now 

 Decoded exception
syntax error, unexpected end of file
in file modules/oneallsociallogin/controllers/front/register.php at line 164
Source file: modules/oneallsociallogin/controllers/front/register.php

145:                    $smarty->assign('oasl_last_name', (isset($data['user_last_name']) ? $data['user_last_name'] : ''));
146:                    $smarty->assign('oasl_newsletter', 1);
147:                }
148:
149:                // Assign template vars.
150:                $smarty->assign('identity_provider', $data['identity_provider']);
151:                $smarty->assign('oasl_register', $this->context->link->getModuleLink('oneallsociallogin', 'register'));
152:
153:                // Show our template.
154:                $this->setTemplate('oneallsociallogin_register.tpl');
155:            }
156:        }
157:
158:        // We could not extract the data.
159:        if ($have_error)
160:        {
161:            $back = trim(Tools::getValue('back'));
162:            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
163:            Tools::redirect($back);
164:        }

Stack trace
1. ./index.php:33 source DispatcherCore->dispatch() 

 

Link to comment
Share on other sites

  • 0

First of all, you should enable debug mode when you are debugging the site 🙂 You can use my 'Advanced debug mode' module that will make sure that you will always use debug mode, yet your customers will use normal mode.

Anyway, back to the error at hand - your file is missing ending brackets }

Take original file, find line 161:

          Tools::redirect();

and replace it with these three lines:

 

            $back = trim(Tools::getValue('back'));
            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
            Tools::redirect($back);

Don't change anything else.

  • Like 1
Link to comment
Share on other sites

  • 0

OK have installed your module .Did as asked ,now getting

Too few arguments to function ToolsCore::redirect(), 0 passed in /home/u564696606/domains/pewterworld.co.uk/public_html/modules/oneallsociallogin/controllers/front/register.php on line 161 and at least 1 expected
in file classes/Tools.php at line 152
Source file: classes/Tools.php

133:            try {
134:                return random_bytes($length);
135:            } catch (Exception $e) {}
136:        }
137:
138:        return '';
139:    }
140:
141:    /**
142:     * Redirect user to another page
143:     *
144:     * @param string       $url     Desired URL
145:     * @param string       $baseUri Base URI (optional)
146:     * @param Link         $link
147:     * @param string|array $headers A list of headers to send before redirection
148:     *
149:     * @since   1.0.0
150:     * @version 1.0.0 Initial version
151:     */
152:    public static function redirect($url, $baseUri = __PS_BASE_URI__, Link $link = null, $headers = null)
153:    {
154:        if (!$link) {
155:            $link = Context::getContext()->link;
156:        }
157:
158:        if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link) {
159:            if (strpos($url, $baseUri) === 0) {
160:                $url = substr($url, strlen($baseUri));
161:            }
162:            if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) {

Stack trace
1. modules/oneallsociallogin/controllers/front/register.php:161 source ToolsCore::redirect()
2. classes/controller/Controller.php:208 source OneAllSocialLoginRegisterModuleFrontController->initContent()
3. classes/controller/FrontController.php:255 source ControllerCore->run()
4. classes/Dispatcher.php:852 source FrontControllerCore->run()
5. ./index.php:33 source DispatcherCore->dispatch() 

 

Link to comment
Share on other sites

  • 0

It now looks like this

  // We could not extract the data.
        if ($have_error)
        {
             $back = trim(Tools::getValue('back'));
            $back = (!empty($back) ? $back : oneall_social_login_tools::get_current_url());
            Tools::redirect($back);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...