示例#1
0
    def post(self, request, *args, **kwargs):
        user = self.request.user

        token = models.Token.objects.create(user=user, name="login")
        user_logged_in.send(sender=user.__class__, request=self.request, user=user)

        data = serializers.TokenSerializer(token, include_plain=True).data
        return Response(data)
示例#2
0
    def post(self, request, *args, **kwargs):
        user = self.request.user

        token = models.Token.objects.create(
            user=user,
            name="login",
            perm_manage_tokens=True,
            max_age=timedelta(days=7),
            max_unused_period=timedelta(hours=1))
        user_logged_in.send(sender=user.__class__,
                            request=self.request,
                            user=user)

        data = serializers.TokenSerializer(token, include_plain=True).data
        return Response(data)
示例#3
0
 def _finalize_with_domain(self, domain):
     if domain.is_locally_registrable:
         # TODO the following line raises Domain.DoesNotExist under unknown conditions
         PDNSChangeTracker.track(lambda: DomainViewSet.auto_delegate(domain))
         token = models.Token.objects.create(user=domain.owner, name='dyndns')
         return Response({
             'detail': 'Success! Here is the password ("token") to configure your router (or any other dynDNS '
                       'client). This password is different from your account password for security reasons.',
             'domain': serializers.DomainSerializer(domain).data,
             **serializers.TokenSerializer(token, include_plain=True).data,
         })
     else:
         return Response({
             'detail': 'Success! Please check the docs for the next steps, https://desec.readthedocs.io/.',
             'domain': serializers.DomainSerializer(domain, include_keys=True).data,
         })