Files
stu_teacher/core/__pycache__/deps.cpython-310.pyc
T

27 lines
2.5 KiB
Plaintext
Raw Normal View History

2026-09-21 23:17:51 +08:00
o
±j‹ ã@s¶ddlmZmZmZddlmZmZddlZddlm Z ddl
m Z ddl m
Z
ddlmZedd �Zeeƒee
ƒfd
ed e d efd
d„Zdefdd„Zd e ded eefdd„ZdS)é)ÚDependsÚ
HTTPExceptionÚstatus)ÚHTTPAuthorizationCredentialsÚ
HTTPBearerN)ÚSession)Údecode_access_token)Úget_db)ÚUserF)Ú
auto_errorÚ credentialsÚdbÚreturncCs¨|durttjdddid�‚zt|jƒ}Wntjy#tddd�‚tjy0tdd d�‚wt|d
ƒ}|  t
¡  t
j |kt
j
d k¡ ¡}|durRtdd d�‚|S)
u†
解� JWT 并返回当�登录用户(model.user.User 对象)
未登录 / token 无效 / 用户�存在 �抛 401
Nu未登录,请先获å�– tokenzWWW-AuthenticateÚBearer)Ú status_codeÚdetailÚheadersi‘u!token 已过期,请é‡�新登录©rru token 无效Úsubru用户ä¸�存在或已被ç¦�用)rrÚHTTP_401_UNAUTHORIZEDrr ÚjwtÚExpiredSignatureErrorÚInvalidTokenErrorÚintÚqueryr
ÚfilterÚuser_idÚ
is_deletedÚfirst)r r
ÚpayloadrÚuser©r!úPC:\Users\Windows\WorkBuddy\2026-09-21-19-29-22\walin_student_system\core\deps.pyÚget_current_users*ý  ÿ ý r#Úrolescs"ttƒfdtdtf‡fdd„
}|S)um
角色级 RBAC �赖工厂。
用法:user: User = Depends(require_roles("admin", "teacher"))
r rcs0|jˆvrttjdd ˆ¡›d|j›�d�‚|S)Nuæ�ƒé™�ä¸�足,需è¦�角色:z / u,当å‰�角色:r)ÚrolerrÚHTTP_403_FORBIDDENÚjoin)r ©r$r!r"Úchecker6s