Skip to content

User auth #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/merlin/wizards/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def __call__(self, request, *args, **kwargs):

slug = kwargs.get('slug', None)

"""Check if the user is authenticated"""
if not request.user.is_authenticated():
request.session['is_authenticated'] = False
return self.user_not_auth_redirect(request)

if not slug:
raise Http404()

Expand Down Expand Up @@ -485,3 +490,16 @@ def done(self, request):
raise NotImplementedError("Your %s class has not defined a done() " \
"method, which is required." \
% self.__class__.__name__)

def user_not_auth_redirect(self, request):
"""
Responsible for redirect to another url when the user is not authenticated.
This function needs to return a ``HttpResponse`` object.

:param request:
A ``HttpRequest`` object that carries along with it the session
used to access the wizard state.
"""
raise NotImplementedError("Your %s class has not defined a redirect " \
"when the user is not logged." \
% self.__class__.__name__)