def decorator(view_func):
def _wrapped_view(request, *args, **kwargs):
iUser = UserInfo.objects.get(username=request.user)
# 判断用户如果是超级管理员则具有所有权限
if not iUser.is_superuser:
if not iUser.role: # 如果用户无角色,直接返回无权限
return HttpResponseRedirect(reverse('permission_deny'))
MariaDB [adminset]> select * from accounts_userinfo;
+----+-------------------------------------------------------------------------------+---------------------+----------+-------------------+-----------+--------------+----------+---------+-----------+
| id | password | last_login | username | email | is_active | is_superuser | nickname | role_id | ldap_name |
+----+-------------------------------------------------------------------------------+---------------------+----------+-------------------+-----------+--------------+----------+---------+-----------+
| 1 | pbkdf2_sha256$36000$b0wLrovVzob2$Dvvix2zjid1DbJdkPjBkjncLeT8BlXuqj112HaqlSzk= | 2018-10-29 16:55:54 | 015208 | 015208@zjtlcb.com | 1 | 1 | NULL | NULL | |
| 2 | pbkdf2_sha256$36000$UYXP1ELpOvE5$DqkptuRi0izyorJMJBURQbKXxPWJHuPMLHw/U0wIw1c= | 2018-10-29 16:44:10 | 015209 | 015209@zjtlcb.com | 1 | 0 | 015209 | 1 | |
+----+-------------------------------------------------------------------------------+---------------------+----------+-------------------+-----------+--------------+----------+---------+-----------+
2 rows in set (0.00 sec)