def create_token(self, customer): token_repo = CustomerTokenRepository() customer_token = Helpers.access_token() return token_repo.store({ 'id': Helpers.generate_unique_code().__str__(), 'token': customer_token, 'customer_id': customer.id })
def legacy_login(self, request): data = request.json customer = CustomerRepository().filter_attribute( {'email': data['email']}) if customer: validate = Helpers.validate_hash_password(data['password'], customer.password) if validate: token_repo = CustomerTokenRepository() customer_token = Helpers.access_token() return self.create_token(customer) raise WalletException('Invalid credentials', 422)