当前位置:网站首页>Flask blog practice - realize personal center and authority management
Flask blog practice - realize personal center and authority management
2022-06-25 10:14:00 【Light programming】
So far in the tutorial, we have already finished the content 95%, Learning is like sailing against the current , move forward , or you 'll fall behind , This is especially true of Internet technology , So no matter what you learn, you should write 、 Think about it 、 To practice , Often things that seem very simple can't be done by themselves , Either lack of programming thinking or weak foundation , Whatever the reason , You can make up for it by practicing hard , Knowledge sharing is also a means of learning , I wish every student who sees this tutorial and can stick to it here have a successful study !
Realize the authority management
The well-known management permission model in the management background generally follows RABC Model to implement , If this part is expanded , That's like another tutorial , So our blog is very simple , It is the simplest way to manage permissions , It also provides you with a flask An idea of permission configuration !
Our users are currently classified into two categories , One is super administrator , One is ordinary users , Have all permissions for Super Administrator , You can visit any of the websites url, Then ordinary users are the users who register and log in , In addition to the public url Only authorized url, This permission is based on url To achieve , The control is rough , But enough to say !
stay app/auth/views/auth.py Medium load_logged_in_user Method , The code is as follows :
@bp.before_app_request
def load_logged_in_user():
# Before every request session View in user_id To get users
# Registered users are those that non administrator users are allowed to view after logging in url
urls = ['/auth/']
user_id = session.get('user_id')
if user_id is None:
g.user = None
边栏推荐
- The path of Architects
- 2台三菱PLC走BCNetTCP协议,能否实现网口无线通讯?
- manhattan_ Slam environment configuration
- [MySQL learning notes 21] storage engine
- ShardingSphere-Proxy 5.0 分库分表(一)
- 什么是 CRA
- Swift recursively queries the array for the number closest to the specified value
- Exception: gradle task assemblydebug failed with exit code 1
- Learning notes of rxjs takeuntil operator
- Fluent: target support file /pods runner / pods runner frameworks Sh: permission denied - stack overflow
猜你喜欢
Request&Response有这一篇就够了
【论文阅读|深读】DRNE:Deep Recursive Network Embedding with Regular Equivalence
Can two Mitsubishi PLC adopt bcnettcp protocol to realize wireless communication of network interface?
Mqtt beginner level chapter
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
Bitmap is converted into drawable and displayed on the screen
Basic usage and principle of schedulemaster distributed task scheduling center
CyCa 2022 children's physical etiquette primary teacher class Shenzhen headquarters station successfully concluded
[buuctf.reverse] 117-120
How much does a wechat applet cost? Wechat applet development and production costs? Come and have a look
随机推荐
Fluent: target support file /pods runner / pods runner frameworks Sh: permission denied - stack overflow
Shardingsphere proxy 4.1 Sous - base de données sous - table
What are the PMP scores?
宏的运用接续符\
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
[buuctf.reverse] 121-125
Swift recursively queries the array for the number closest to the specified value
Floating window --- create an activity floating window (can be dragged)
How to make a self-made installer and package the program to generate an installer
The way that flutter makes the keyboard disappear (forwarding from the dependent window)
我希望按照我的思路尽可能将canvas基础讲明白
字符串 实现 strStr()
DDS learning notes of opendds
Shuttle JSON, list, map inter transfer
Android database security: after the user exits, the transaction rollback log still stores relevant data information
WPF Prism框架
新学派:不诈骗经济学
MongoDB的原理、基本使用、集群和分片集群
Learning notes of rxjs takeuntil operator
Jetpack compose layout (I) - basic knowledge of layout