Remove unnecessary decorator. Add doc.
This commit is contained in:
parent
b79c68fd7b
commit
7d6272b668
3 changed files with 4 additions and 19 deletions
|
@ -1,18 +0,0 @@
|
||||||
from django.contrib.auth import REDIRECT_FIELD_NAME
|
|
||||||
from django.contrib.auth.decorators import user_passes_test
|
|
||||||
|
|
||||||
|
|
||||||
def staff_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None):
|
|
||||||
"""
|
|
||||||
Decorator for views that checks that the user is logged in and is staff,
|
|
||||||
redirecting to the log-in page if necessary.
|
|
||||||
"""
|
|
||||||
actual_decorator = user_passes_test(
|
|
||||||
lambda u: u.is_authenticated() and u.is_staff,
|
|
||||||
login_url=login_url,
|
|
||||||
redirect_field_name=redirect_field_name
|
|
||||||
)
|
|
||||||
if function:
|
|
||||||
return actual_decorator(function)
|
|
||||||
|
|
||||||
return actual_decorator
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
class Params(object):
|
class Params(object):
|
||||||
|
'''
|
||||||
|
The purpose of this class is for accesing params via dot notation.
|
||||||
|
'''
|
||||||
pass
|
pass
|
|
@ -24,7 +24,7 @@ def create_id_token_dic(user, iss, aud):
|
||||||
user_auth_time = time.mktime(user.last_login.timetuple())
|
user_auth_time = time.mktime(user.last_login.timetuple())
|
||||||
|
|
||||||
dic = {
|
dic = {
|
||||||
'iss': iss, # TODO: this should not be hardcoded.
|
'iss': iss,
|
||||||
'sub': user.id,
|
'sub': user.id,
|
||||||
'aud': aud,
|
'aud': aud,
|
||||||
'exp': exp_time,
|
'exp': exp_time,
|
||||||
|
|
Loading…
Reference in a new issue