Skip to content
Snippets Groups Projects
Commit 86e2136d authored by Jonathan Seguin's avatar Jonathan Seguin
Browse files

check and return error if token auth fails (mixin only)

parent 9e7dace5
No related branches found
No related tags found
1 merge request!68Resolve "Implement pubkey à la gitlab/github (ou simple token), pour permettre un accès sans fournir son mot de passe"
......@@ -19,7 +19,11 @@ class TokenLoginMixin(LoginRequiredMixin):
def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated:
user = authenticate(request)
login(request, user)
if user:
login(request, user)
else:
return JsonResponse({'error': _('Malformed authorization header or invalid token')}, status=500)
return super().dispatch(request, *args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment