binshops / prestashop-rest

PrestaShop REST API module to expose your PrestaShop website's REST endpoints
https://www.binshops.com/prestashop-api
Academic Free License v3.0
95 stars 33 forks source link

401 - User not authenticated #6

Closed OguzhanLevent closed 3 years ago

OguzhanLevent commented 3 years ago

Hi, I am using the module and making improvements on it. I created a new controller to update the customer address and extends from the “AbstractAuthRESTController” controller. But when I post to url it returns code 410. During the login process, I accept cookies and attach it in memory. Can you provide information on how the controller “AbstractAuthRESTController” works? My goal is to develop a mobile application on flutter.

samberrry commented 3 years ago

Hi, thanks for reaching out. You can set the cookie just like the browser to get authorized. Please test the endpoint with postman. Plus, the pro version will be release in the next month which includes, all necessary endpoints for a full mobile application like checkout steps, address management, account management and others.

OguzhanLevent commented 3 years ago

Hello again, I've noticed that for now. I can keep cookies, but I made a change to the AbstractrestController class like this.

if(!$this->context->customer->isLogged()){ $this->ajaxRender(json_encode([ 'code' => 410, 'success' => false, 'message' => 'Not Logged.', 'user' => $this->context->customer->id, 'auth' => $this->php_self, ])); die; }

If the result is;

{ "code": 410, "success": false, "message": "giriş yapılmadı.", "user": 50620, "auth": null }

what could be the reason for this? Because $this->context->customer->id returns me results but islogged function response false.