Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Customer register mutation
Pacu274149a470621
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.pyindex bb267d5fa5..99c97dbfce 100644--- a/saleor/graphql/account/mutations.py+++ b/saleor/graphql/account/mutations.py@@ -34,6 +34,29 @@ BILLING_ADDRESS_FIELD = 'default_billing_address'SHIPPING_ADDRESS_FIELD = 'default_shipping_address'+class CustomerRegisterInput(graphene.InputObjectType):+ email = graphene.String(+ description='The unique email address of the user.', required=True)+ password = graphene.String(description='Password', required=True)+++class CustomerRegister(ModelMutation):+ class Arguments:+ input = CustomerRegisterInput(+ description='Fields required to create a user.', required=True)++ class Meta:+ description = 'Register a new user.'+ exclude = ['password']+ model = models.User++ @classmethod+ def save(cls, info, user, cleaned_input):+ password = cleaned_input['password']+ user.set_password(password)+ user.save()++class UserInput(graphene.InputObjectType):email = graphene.String(description='The unique email address of the user.')@@ -111,7 +134,6 @@ class CustomerCreate(ModelMutation):billing_address = cls.construct_address(BILLING_ADDRESS_FIELD, billing_address_input, instance, errors)cleaned_input[BILLING_ADDRESS_FIELD] = billing_address-return cleaned_input@classmethoddiff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex e3e1b69a0d..013424481f 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -4,8 +4,9 @@ from graphene_django.filter import DjangoFilterConnectionFieldfrom graphql_jwt.decorators import login_required, permission_requiredfrom .account.mutations import (- CustomerCreate, CustomerUpdate, PasswordReset, SetPassword, StaffCreate,- StaffDelete, StaffUpdate, AddressCreate, AddressUpdate, AddressDelete)+ CustomerCreate, CustomerUpdate, CustomerRegister, PasswordReset,+ SetPassword, StaffCreate, StaffDelete, StaffUpdate, AddressCreate,+ AddressUpdate, AddressDelete)from .account.types import AddressValidationData, AddressValidationInput, Userfrom .account.resolvers import (resolve_address_validator, resolve_customers, resolve_staff_users)@@ -287,6 +288,7 @@ class Mutations(graphene.ObjectType):customer_create = CustomerCreate.Field()customer_update = CustomerUpdate.Field()+ customer_register = CustomerRegister.Field()staff_create = StaffCreate.Field()staff_update = StaffUpdate.Field()