delphiassistant / permission_control_system Goto Github PK
View Code? Open in Web Editor NEWThis is an SDK which helps you to specify which user group (role) members have access to which actions in controllers.
This is an SDK which helps you to specify which user group (role) members have access to which actions in controllers.
در اینجا، به جای خاصیت Permission به اشتباه نوشته شده Permissions
userPermissions = db.RolePermissions.Include("Permissions")
بهتر است به جای استفاده از string برای متد Include به صورت زیر عمل کرد تا جلوی چنین اشتباهات تایپی گرفته شود
using System.Data.Entity;
------
db.RolePermissions.Include(p => p.Permission)
در اینجا وجود AuthorizeAttribute بر روی Controller و Action ها توسط Reflection بررسی شده است.
1- ولی اگر فیلتر Authorize به صورت سراسری تعریف شده باشد دیگر با این روش توسط Reflection یافت نمی شود. و عملا نادیده گرفته می شود.
2- همچنین وجود خاصیت AllowAnonymous بر روی Controller چک نشده است و موجب پردازش عملیات دسترسی بر روی Controller ای میشود که لازم نیست.
سلام اگر ممکن هست ممنون میشم یک توضیحی در ارتباط با فلسفه وجود این جدول و موارد استفاده اش بگید
ممنون
پیشنهاد هایی برای تمیز کردن و بهبود کد ها
1- تغییر متد Include به حالت Expression Func
2- حذف namespace های اضافی
3- حذف cast های اضافی (مثال)
4- تعریف یک const string سراسری به جای هربار تایپ دستی AffectedUsers
5- استفاده از nameof به جای تایپ دستی اسم پروپرتی ها (مثلا برای ForeignKey)
6- استفاده از nameof به جای تایپ دستی اسم متد ها (مثلا برای اسم اکشن ها)
7- یک دست بودن استفاده از var یا explicit type به هنگام تعریف متغیر ها (الان بعضی جا ها از var و بعضی جا ها از explicit type استفاده شده)
8- چک کردن Attribute ها بر اساس type باشد نه بر اساس name (مثال)
9- استفاده از private readonly برای فیلد های کلاس ها (مثال)
10- حذف عبارات this اضافی (مثال)
11- از امکان تزریق وابستگی موجود در Owin استفاده شود. در اینجا تایپ های لازم رجیستر شده اند. پس میتوان مانند اینجا، آنها را توسط تزریق در سازنده دریافت کرد.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.