@@ -6,7 +6,9 @@ class ResolverCommonAccount extends Resolver
66{
77 public function login ($ args )
88 {
9+ $ this ->load ->model ('common/customer ' );
910 $ customer = new Customer ();
11+
1012 $ authentication = $ customer ->getByEmail (
1113 $ args ["email " ],
1214 $ args ["password " ]
@@ -17,14 +19,19 @@ public function login($args)
1719 } elseif (!$ authentication || !$ customer ->id || $ customer ->is_guest ) {
1820 throw new Exception ('Authentication failed. ' );
1921 } else {
20- $ this ->context ->updateCustomer ($ customer );
22+ if (_PS_VERSION_ > '1.7.0.0 ' ) {
23+ $ this ->context ->updateCustomer ($ customer );
24+ } else {
25+ $ this ->model_common_customer ->updateCustomer ($ customer );
26+ }
2127
2228 Hook::exec ('actionAuthentication ' , ['customer ' => $ this ->context ->customer ]);
2329
2430 CartRule::autoRemoveFromCart ($ this ->context );
2531 CartRule::autoAddToCart ($ this ->context );
2632 }
2733
34+
2835 return $ this ->get ($ customer ->id );
2936 }
3037
@@ -35,7 +42,7 @@ public function logout($args)
3542 $ cookie ->logout ();
3643
3744 return array (
38- 'status ' => true
45+ 'status ' => false
3946 );
4047 }
4148
@@ -52,9 +59,14 @@ public function register($args)
5259 $ customer ->firstname = $ customerData ['firstName ' ];
5360 $ customer ->lastname = $ customerData ['lastName ' ];
5461 $ customer ->email = $ customerData ['email ' ];
55- $ crypto = ServiceLocator::get ('\\PrestaShop \\PrestaShop \\Core \\Crypto \\Hashing ' );
56-
57- $ customer ->passwd = $ crypto ->hash ($ customerData ['password ' ]);
62+
63+ if (_PS_VERSION_ > '1.7.0.0 ' ) {
64+ $ crypto = ServiceLocator::get ('\\PrestaShop \\PrestaShop \\Core \\Crypto \\Hashing ' );
65+ $ customer ->passwd = $ crypto ->hash ($ customerData ['password ' ]);
66+ } else {
67+ $ customer ->passwd = Tools::encrypt ($ customerData ['password ' ]);
68+ }
69+
5870 $ customer ->save ();
5971
6072 return $ this ->get ($ customer ->id );
@@ -81,9 +93,13 @@ public function editPassword($args)
8193 {
8294 global $ cookie ;
8395
84- $ crypto = ServiceLocator::get ('\\PrestaShop \\PrestaShop \\Core \\Crypto \\Hashing ' );
96+ if (_PS_VERSION_ > '1.7.0.0 ' ) {
97+ $ crypto = ServiceLocator::get ('\\PrestaShop \\PrestaShop \\Core \\Crypto \\Hashing ' );
98+ $ this ->context ->customer ->passwd = $ crypto ->hash ($ args ['password ' ]);
99+ } else {
100+ $ this ->context ->customer ->passwd = Tools::encrypt ($ args ['password ' ]);
101+ }
85102
86- $ this ->context ->customer ->passwd = $ crypto ->hash ($ args ['password ' ]);
87103
88104 if (!$ this ->context ->customer ->save ()) {
89105 throw new Exception ("Update failed " );
@@ -122,8 +138,9 @@ public function isLogged($args)
122138
123139 public function address ($ args )
124140 {
125- global $ cookie ;
126- $ result = $ this ->context ->customer ->getSimpleAddress ($ args ['id ' ], $ cookie ->id_lang );
141+ $ this ->load ->model ('common/address ' );
142+
143+ $ result = $ this ->model_common_address ->getAddress ($ args ['id ' ]);
127144
128145 return array (
129146 'id ' => $ args ['id ' ],
@@ -185,6 +202,7 @@ public function addAddress($args)
185202 {
186203 global $ cookie ;
187204 $ addressData = $ args ['address ' ];
205+
188206 $ address = new Address ();
189207 $ address ->alias = 'My Address ' ;
190208 $ address ->id_customer = $ cookie ->id_customer ;
@@ -198,6 +216,7 @@ public function addAddress($args)
198216 $ address ->address1 = $ addressData ['address1 ' ];
199217 $ address ->address2 = $ addressData ['address2 ' ];
200218
219+
201220 if (!$ address ->save ()) {
202221 throw new Exception ("Update failed " );
203222 }
0 commit comments