Custom form authentication / Authorization scheme in ASP.net MVC

后端 未结 4 975
陌清茗
陌清茗 2020-12-23 23:44

I am trying to create a custom authentication scheme in ASP.NET MVC using form authentication. The idea that I might have different areas on the site that will be managed -

4条回答
  •  难免孤独
    2020-12-24 00:17

    i tackled this one before i have a class i use for login

    routines are login, read cookie, check cookie and they have a model that contains

    name, email, id, userlevel

    then you just have your own custom actionFilter

    eg [CustomAuth(MinAllowedLevel=10)]

    i use a baseclass for all my controllers so i can have an easier link to all my session content and can then get info like so

    var model = pictures.all().where(x => x.userid == users.ReadCookie.userID)
    

    i will bob up the code tommorow if you want for you when im back on UK daytime

    say 10 hrs i will let you have the class for all the session stuff and the custom action filter that you can use, then all you need is a logins table with a userlevel field, best with levels of 10,20,30,40 incase you need a level between 1 and 2

提交回复
热议问题