mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Redirect to login if no access
This commit is contained in:
parent
0a91f4a331
commit
6e153d9c09
1 changed files with 9 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
from flask_admin import AdminIndexView
|
||||
from flask_admin.contrib.sqla import ModelView
|
||||
from flask_security import current_user
|
||||
from flask import redirect, request, url_for
|
||||
|
||||
|
||||
def adminViewIsAccessible():
|
||||
|
@ -11,6 +12,10 @@ class SecureAdminIndexView(AdminIndexView):
|
|||
def is_accessible(self):
|
||||
return adminViewIsAccessible()
|
||||
|
||||
def inaccessible_callback(self, name, **kwargs):
|
||||
# Redirect to login page if user doesn't have access
|
||||
return redirect(url_for("security.login", next=request.url))
|
||||
|
||||
|
||||
class SecureModelView(ModelView):
|
||||
can_export = True
|
||||
|
@ -26,3 +31,7 @@ class SecureModelView(ModelView):
|
|||
|
||||
def is_accessible(self):
|
||||
return adminViewIsAccessible()
|
||||
|
||||
def inaccessible_callback(self, name, **kwargs):
|
||||
# Redirect to login page if user doesn't have access
|
||||
return redirect(url_for("security.login", next=request.url))
|
||||
|
|
Loading…
Reference in a new issue