send to api

This commit is contained in:
Cayo Puigdefabregas 2024-03-25 16:19:40 +01:00
parent 6dbd5d18a5
commit 59c99d8279
1 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import json
import base64
import logging
import requests
from django.template import loader
from django.core.mail import EmailMultiAlternatives
@ -149,10 +150,16 @@ class VerifyView(View):
for user in User.objects.filter(is_admin=True):
self.send_email(user)
self.send_api()
response["response"] = "Validation Code {}".format(code)
return JsonResponse(response)
def send_api(self):
data = {"vp": self.vp_token.vp_token, "code": self.vp_token.code}
url = self.vp_token.org.response_uri
requests.post(url, data=data)
def validate(self, request):
auth_header = request.headers.get('Authorization', b'')
auth_data = auth_header.split()