def post(self, request, *args, **kwargs): data = request.data serializer = RegisterSerializer(data=data) if serializer.is_valid(raise_exception=True): user = serializer.save() send_activation_mail(user) return Response('Аккаунт успешно создан')
def post(self, request): data = request.data serializer = RegisterSerializer(data=data) if serializer.is_valid(raise_exception=True): serializer.save() return Response("Successfully signed up!", status=status.HTTP_201_CREATED)
def post(self, request, format=None): serializer = RegisterSerializer(data=request.data) if serializer.is_valid(raise_exception=True): user = serializer.save() send_activation_mail(user) return Response("User successfully registered", status=status.HTTP_201_CREATED)
def post(self,request): data = request.data serializer = RegisterSerializer(data=data) if serializer.is_valid(raise_exception=True): user = serializer.save() send_activation_email(user) return Response('Account has created succesfully!',status=status.HTTP_201_CREATED)
def post(request, *args, **kwargs): """создаем метод пост потому что POST отвечает за изменения на серевере. Это HTTP запрос""" data = request.data # данные приходят в виде словаря serializer = RegisterSerializer(data=data) if serializer.is_valid(raise_exception=True): user = serializer.save() send_activation_mail(user) return Response(serializer.data) return Response('Аккаунт успешно создан')
def post(self, request, *args, **kwargs): user_ser_obj = RegisterSerializer(data=request.data) if user_ser_obj.is_valid(): user_ser_obj.save() return Response(user_ser_obj.validated_data, status=status.HTTP_201_CREATED) else: return Response(user_ser_obj.errors, status=status.HTTP_400_BAD_REQUEST)
def register_view(request): if request.method == 'POST': serializer = RegisterSerializer(data=request.data) data = {} if serializer.is_valid(): account = serializer.save() data['Response'] = "Your account Register" data['username'] = account.username data['email'] = account.email data['password'] = account.password data['phone'] = account.phone token = Token.objects.get(user=account).key data['token'] = token else: data = serializer.errors return Response(data)
def post(self, request): user = request.data serializer = RegisterSerializer(data=user) current_site = get_current_site(request).domain relativeLink = reverse('email-verify') token = RefreshToken.for_user(user).access_token absurl = 'http://' + current_site + relativeLink + "?token=" + str( token) email_body = 'Hi, ' + user.username + ' Use link below to verify your email \n' + absurl data = { 'email_body': email_body, 'to_email': user.email, 'email_subject': 'Verify your email' } SendMailUtil.send_email(data) if serializer.is_valid(raise_exception=True): serializer.save() return Response('Successfully signed up', status=status.HTTP_201_CREATED)
def post(self, request): serializer = RegisterSerializer(data=request.DATA) if serializer.is_valid(): full_name = serializer.data["full_name"].strip() if len(full_name.split(" ")) > 1: first_name = full_name.split(" ")[0] last_name = " ".join(full_name.split(" ")[1:]) else: first_name = full_name last_name = None email = serializer.data["email"].strip() password = serializer.data["password"].strip() # Create the user user = User.objects.create( username=email, email=email, full_name=full_name, first_name=first_name, last_name=last_name, modified=now(), ) user.set_password(password) user.save() # Create token for native applications token, created = Token.objects.get_or_create(user=user) # Set the new token data = {"token": token.key} user = UserSerializer(token.user) data.update(user.data) return Response(data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def post(self, request): # Get the IP of the user. client_ip, is_routable = get_client_ip(self.request) # Save our code and return the serialized data. serializer = RegisterSerializer(data=request.data, context={ 'request': request, }) serializer.is_valid(raise_exception=True) data = serializer.save() # Get the newly created user from the registration. authenticated_user = data['user'] # Send our activation email to the user. django_rq.enqueue(run_send_activation_email_func, email=authenticated_user.email) django_rq.enqueue(run_send_user_was_created_to_staff_email_func, email=authenticated_user.email) # Return a simple message indicating that the user was registered. return Response(data={}, status=status.HTTP_201_CREATED)