Hi,
How to restrict the user to visit the page/analysis?
There will has a master table which store the username and role_id
and
a table which stored all the role_id with the module_id that the role can access.
authority_table
id role_id module_id
31000001 1 21000001
31000002 1 21000002
31000003 1 21000003
31000004 1 21000004
31000005 2 21000001
31000006 2 21000002
31000007 2 21000004
role_id name
1 admin
2 finance
from the above table, will extract the data as per below code:
SELECT *
FROM authority_table
WHERE role_id IN (SELECT role_id FROM master_table WHERE username = @user)
each page will register under the module_id
analysis1.py
require_login(__name__,
access_level= '21000001'
)
analysis2.py
require_login(__name__,
access_level= '21000002'
)
analysis3.py
require_login(__name__,
access_level= '21000003'
)