@labdigital/commercetools-mock 0.5.20 → 0.5.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3934,6 +3934,7 @@ class MyCustomerService extends AbstractService {
3934
3934
  this.extraRoutes(router);
3935
3935
  router.get('', this.getMe.bind(this));
3936
3936
  router.post('/signup', this.signUp.bind(this));
3937
+ router.post('/login', this.signIn.bind(this));
3937
3938
  parent.use(`/${basePath}`, router);
3938
3939
  }
3939
3940
 
@@ -3958,6 +3959,31 @@ class MyCustomerService extends AbstractService {
3958
3959
  });
3959
3960
  }
3960
3961
 
3962
+ signIn(request, response) {
3963
+ const {
3964
+ email,
3965
+ password
3966
+ } = request.body;
3967
+ const encodedPassword = Buffer.from(password).toString('base64');
3968
+ const result = this.repository.query(request.params.projectKey, {
3969
+ where: [`email = "${email}"`, `password = "${encodedPassword}"`]
3970
+ });
3971
+
3972
+ if (result.count === 0) {
3973
+ return response.status(400).send({
3974
+ message: 'Account with the given credentials not found.',
3975
+ errors: [{
3976
+ code: 'InvalidCredentials',
3977
+ message: 'Account with the given credentials not found.'
3978
+ }]
3979
+ });
3980
+ }
3981
+
3982
+ return response.status(200).send({
3983
+ customer: result.results[0]
3984
+ });
3985
+ }
3986
+
3961
3987
  }
3962
3988
 
3963
3989
  const DEFAULT_OPTIONS = {