Jump to content

AJAX login


Recommended Posts

Hello Dear Friends !

 

I have got a big problem with customizing my prestashop 1.6 . I'd like to create login and registration in fancybox. I've created this, and now I've got small form in fancybox. I've read in API docs, that I have to call my login method in url by http://mydomain.com/....&ajax. I've tried to do like that, I copied link to auth module (by firebug) and it seems like that:

 

 

<form id="login_form" method="post" action="index.php?controller=authentication&ajax">

 

when I click on submit button I try to show results by ajax:

 

 

$('form#login_form').submit(function(e) {
                e.preventDefault();
                var data = $(this).serialize();
                
                $.ajax({
                    type: "POST",
                    url: "index.php?controller=authentication&ajax",
                    data: data,
                    dataType: 'json',
                    success: function(html){
                        console.log(html);
                    },
                    error: function() {
                        alert('error');
                    }
                });
                
            });

 

but it seems, that I got results from controller Auth, method initContent, as I get in json answerd fields like : 'hasError', 'errors', 'page', 'token';

 

'hasError' is set to false, 'errors' is empty.

 

How can I call a method processSubmitLogin from AuthController (I think there is authentication mechanism) ?

 

I would be very grateful if anyone could help me ...

 

Greetings.

Link to comment
Share on other sites

  • 4 months later...
  • 4 weeks later...

Hi, I am dealing with the same issue , ajax login with callback.

 

I'd like to know how do you update user info block status when a customer successfully logged in ?

 

I've put these as callback information in processSubmitLogin() method

$return = array(
                'hasError' => !empty($this->errors),
                'errors' => $this->errors,
                'token' => Tools::getToken(false),
                'lastname' => $customer->lastname,
                'firstname' => $customer->firstname,
                'isLogged' => true
            );
            $this->ajaxDie(Tools::jsonEncode($return));

How could I inform nav.tpl that isLogged= true, so that it updates its content ?

 

Thanks in advance for your reply.

 

Best Regards 

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...