@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.
@@ -3941,6 +3941,7 @@ class MyCustomerService extends AbstractService {
3941
3941
  this.extraRoutes(router);
3942
3942
  router.get('', this.getMe.bind(this));
3943
3943
  router.post('/signup', this.signUp.bind(this));
3944
+ router.post('/login', this.signIn.bind(this));
3944
3945
  parent.use(`/${basePath}`, router);
3945
3946
  }
3946
3947
 
@@ -3965,6 +3966,31 @@ class MyCustomerService extends AbstractService {
3965
3966
  });
3966
3967
  }
3967
3968
 
3969
+ signIn(request, response) {
3970
+ const {
3971
+ email,
3972
+ password
3973
+ } = request.body;
3974
+ const encodedPassword = Buffer.from(password).toString('base64');
3975
+ const result = this.repository.query(request.params.projectKey, {
3976
+ where: [`email = "${email}"`, `password = "${encodedPassword}"`]
3977
+ });
3978
+
3979
+ if (result.count === 0) {
3980
+ return response.status(400).send({
3981
+ message: 'Account with the given credentials not found.',
3982
+ errors: [{
3983
+ code: 'InvalidCredentials',
3984
+ message: 'Account with the given credentials not found.'
3985
+ }]
3986
+ });
3987
+ }
3988
+
3989
+ return response.status(200).send({
3990
+ customer: result.results[0]
3991
+ });
3992
+ }
3993
+
3968
3994
  }
3969
3995
 
3970
3996
  const DEFAULT_OPTIONS = {