MVC 3 - access for specific user only

前端 未结 2 1557
陌清茗
陌清茗 2021-01-01 05:14

In my web application registered users can add new content and edit it later. I want only the content\'s author to be able to edit it. Is there any smart way of doing this o

2条回答
  •  春和景丽
    2021-01-01 05:31

    I would:

    1. Save the db.aspnet_Users columm UserId (Guid) against the content record
    2. Write an extension method for your content model which verifies the current users Guid against the saved contents User Guid
    3. I would write some code that overrides this functionality for your Admin logins (I would create an Admin Role).

提交回复
热议问题