Skip to content

Commit

Permalink
bug(verification):add verification base url (#39)
Browse files Browse the repository at this point in the history
-add verification base url to environment variables

[Starts #164029748]
  • Loading branch information
sylviawanjiku authored and younggeeks committed Feb 19, 2019
1 parent cd27266 commit afb3a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions authors/apps/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
EmailCheckSerializer, PasswordResetSerializer, ActivateSerializer,
)
from .backends import get_jwt_token
activation_url = os.getenv('ACTIVATION_URL')


class RegistrationAPIView(CreateAPIView):
Expand All @@ -36,7 +37,7 @@ class RegistrationAPIView(CreateAPIView):

def post(self, request):
user = request.data.get('user', {})

# The create serializer, validate serializer, save serializer pattern
# below is common and you will see it a lot throughout this course and
# your own work later on. Get familiar with it.
Expand Down Expand Up @@ -70,7 +71,7 @@ def post(self, request):
# create activation link
activation_link = "{scheme}://{host}{route}".format(
scheme=request.scheme,
host=request.get_host(),
host=activation_url,
route=url
)
username = user_to_activate.username
Expand Down Expand Up @@ -192,7 +193,7 @@ def post(self, request):
"exp": datetime.utcnow() + timedelta(hours=1)},
os.getenv('SECRET_KEY'), algorithm='HS256').decode()

hosting = request.get_host()
hosting = activation_url

my_link = \
'https://' + hosting + '/api/users/password-done/{}'.format(token)
Expand Down Expand Up @@ -278,3 +279,4 @@ def create(self, request, *args, **kwargs):
serializer_data = serializer.data
serializer_data["token"] = get_jwt_token(user)
return Response(serializer_data, status=status.HTTP_200_OK)

6 changes: 3 additions & 3 deletions authors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
]

MIDDLEWARE_CLASSES = (
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.BrokenLinkEmailsMiddleware',
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.BrokenLinkEmailsMiddleware',
'django.middleware.common.CommonMiddleware',
)
CORS_ORIGIN_ALLOW_ALL = True

Expand Down

0 comments on commit afb3a45

Please sign in to comment.