From 6f9a9056cbf04831e739ed8b28174e46f393d8f2 Mon Sep 17 00:00:00 2001 From: Josue Kouka Date: Thu, 20 Apr 2017 10:53:07 +0200 Subject: [PATCH 2/6] add redirect to unauthorized page function --- src/authentic2/templates/authentic2/unauthorized.html | 10 ++++++++++ src/authentic2/utils.py | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 src/authentic2/templates/authentic2/unauthorized.html diff --git a/src/authentic2/templates/authentic2/unauthorized.html b/src/authentic2/templates/authentic2/unauthorized.html new file mode 100644 index 00000000..f9569fd7 --- /dev/null +++ b/src/authentic2/templates/authentic2/unauthorized.html @@ -0,0 +1,10 @@ +{% extends "authentic2/base-page.html" %} +{% load i18n gadjo %} + +{% block page-title %} + {{ block.super }} - {% trans "Access denied" %} +{% endblock %} + +{% block content %} +{% trans "You are not authorized to access this service, please contact your administrator." %} Back +{% endblock %} diff --git a/src/authentic2/utils.py b/src/authentic2/utils.py index cc0d0f4d..4e091fe5 100644 --- a/src/authentic2/utils.py +++ b/src/authentic2/utils.py @@ -36,6 +36,7 @@ from django.utils.functional import empty from django.template import RequestContext from django.utils.http import urlsafe_base64_encode from django.utils.encoding import force_bytes +from django.shortcuts import render try: @@ -834,3 +835,8 @@ def human_duration(seconds): if seconds: s.append(ungettext('%s second', '%s seconds', seconds) % seconds) return ', '.join(s) + + +def redirect_to_unauthorized(request, service): + context = {'callback_url': service.unauthorized_url} + return render(request, 'authentic2/unauthorized.html', context=context) -- 2.11.0