Hi, I hope any of you can help me out.
I am trying build user registrations by using rest-auth/registration API.
However, after rest-auth/registration send data which has an email, a
company name, a user name, and etc to ResisterSerializer, it ONLY
recognizes an email data.
Here is my rest-auth/registration code.
axios.post(`${process.env.API_ENDPOINT}rest-auth/registration/`,
{
company: this.company,
username: this.username,
email: this.email,
password1: this.password1,
password2: this.password2
}).then(res => {
this.$router.push('/login')
})
.catch(function(error){
this.nonFieldErrors = error.response.data
})
.finally(() => this.loading = false)
and this is ResisterSerializer code below.
class RegisterSerializer(serializers.Serializer):
company = serializers.CharField(required=True)
username = serializers.CharField(required=True)
email = serializers.EmailField(required=allauth_settings.EMAIL_REQUIRED)
password1 = serializers.CharField(required=True)
password2 = serializers.CharField(required=True)
def validate_email(self, email):
email = get_adapter().clean_email(email)
if allauth_settings.UNIQUE_EMAIL:
if email and email_address_exists(email):
raise serializers.ValidationError(
_("A user is already registered with this e-mail
address."))
return email
def validate_password1(self, password):
return get_adapter().clean_password(password)
def validate(self, data):
if data['password1'] != data['password2']:
raise serializers.ValidationError(
_("The two password fields didn't match."))
return data
def get_cleaned_data(self):
return {
'company': self.validated_data.get('company', ''),
'username': self.validated_data.get('username', ''),
'password1': self.validated_data.get('password1', ''),
'email': self.validated_data.get('email', ''),
}
def save(self, request):
adapter = get_adapter()
user = adapter.new_user(request)
self.cleaned_data = self.get_cleaned_data()
adapter.save_user(request, user, self)
setup_user_email(request, user, [])
user.save()
return user
class VerifyEmailSerializer(serializers.Serializer):
key = serializers.CharField()
Could you please give me advises.
Thank you very much.
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.