Jump to content

Login functionality as webservice api


Ljj

Recommended Posts

I have created a new custom routing under src/Prestashopbundle/resources/config/api/custom_routing.yml

custom_routing.yml is the file i have created

api_customer_login:

    path: /logincustomer

    methods: [GET | POST]

    defaults:

    _controller: controllers/front/AuthController:initContent

 

And in app/cache/prod/appProdProjectContainerUrlGenerator.php this file i have added the link route in function __construct

  'api_customer_login' => array (  0 =>   array (  ),  1 =>   array (    '_controller' => 'controllers/front/AuthController:initContent',  ),  2 =>   array (    '_method' => 'POST',  ),  3 =>   array (    0 =>     array (      0 => 'text',      1 => '/addons/login',    ),  ),  4 =>   array (  ),  5 =>   array (  ),)

And in app/cache/prod/appProdProjectContainerUrlMatcher.php this. file i have added this link

   // Customer_login custom

             if ($pathinfo === '/api/logincustomer') {

                // if ($this->context->getMethod() != 'POST') {

                //     $allow[] = 'POST';

                if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {

                    $allow = array_merge($allow, array('GET', 'HEAD'));

                    goto not_api_customer_login;

                }

 

And in WebserviceRequest.php i want add this resources , but am not getting how to add

now i have add like this

  'logincustomer' => array('description' => 'Customers login','class' => 'Customer')

so when i pass this api i am getting id's of customers

 

Can you pls tell me how to achieve this login functionality as api

Link to comment
Share on other sites

Basically do the same as the PrestaShop login form does, which is (for v1.5 at least):

Sending a POST request to http(s)://yourshop.com/index.php?controller=authentication with the following parameters:

email: your customer's email address

passwd: your customer's password

back: name of the controller you want to be redirected to after success (ex: my-account)

SubmitLogin: put anything there, it just needs to be true, so that the controller knows it's a login action

If it doesn't work, your version may work differently and you will have to check the network tab of your favourite developer tool, to see what kind of request is sent with which parameters.

 

tired this also but  no use..can anyone pls help

 

Link to comment
Share on other sites

Hi 

Any ideas how it works after declaring resources in webservicerequest.php

 public static function getResources()

    {

        $resources = array(

            'addresses' => array('description' => 'The Customer, Brand and Customer addresses','class' => 'Address'),

        );

}

after this function how it navigates?

 

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