GithubHelp home page GithubHelp logo

delphiassistant / permission_control_system Goto Github PK

View Code? Open in Web Editor NEW
36.0 1.0 5.0 21.88 MB

This is an SDK which helps you to specify which user group (role) members have access to which actions in controllers.

C# 43.26% CSS 38.68% ASP 0.02% HTML 15.91% JavaScript 2.13%
asp-net-mvc mvc5 identity permissions roles-management role-permissions

permission_control_system's Issues

RolePermissons dose not contains Permissions property

در اینجا، به جای خاصیت Permission به اشتباه نوشته شده Permissions

userPermissions = db.RolePermissions.Include("Permissions")

بهتر است به جای استفاده از string برای متد Include به صورت زیر عمل کرد تا جلوی چنین اشتباهات تایپی گرفته شود

using System.Data.Entity;
------
db.RolePermissions.Include(p => p.Permission)

Bug : Working with Global Authorize Filter and AllowAnonymous Attribute

در اینجا وجود AuthorizeAttribute بر روی Controller و Action ها توسط Reflection بررسی شده است.

1- ولی اگر فیلتر Authorize به صورت سراسری تعریف شده باشد دیگر با این روش توسط Reflection یافت نمی شود. و عملا نادیده گرفته می شود.

2- همچنین وجود خاصیت AllowAnonymous بر روی Controller چک نشده است و موجب پردازش عملیات دسترسی بر روی Controller ای میشود که لازم نیست.

Suggestion : Code Cleanup and Improvements

پیشنهاد هایی برای تمیز کردن و بهبود کد ها

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 استفاده شود. در اینجا تایپ های لازم رجیستر شده اند. پس میتوان مانند اینجا، آنها را توسط تزریق در سازنده دریافت کرد.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.