c# - MVC [Authorize] Extension to only check an 'enabled' bit flag -
i'm using ef code first , asp.net mvc 4. users sign in site exclusively oauth providers, not native accounts. i've got working no problem, users table part of standard model , webpages_oauthmembership holding oauth data. i've added 'enabled' bit field on users table that, while site still in 'alpha', users not have access site unless approve it. users can create oauth accounts want isolate specific controllers using annotation prevent use. instance, have 'widgets' controller. right set [authorize] users must logged in. want own custom annotation, [approved] or [enabled], logged in, users cannot proceed unless i've flipped bit 'on' in users table. while write own helper method , inject manually, i'd rather use annotations it's easier roll out , remove once site live.
in future, if website ever charged money, i'd love swap out [enabled] check see if user date, payments wise. feel annotation right way go, not sure 100% how it, , there's not membership faculty out there i'm ignorant of.
thanks!
why don't add check enabled bit when validate login? can prevent non-enabled users logging in (not sure why want them log in not able access pages.. kind of silly).
alternatively, can use roles this. add users "enabled" role, , configure pages allow access role. seems lot easier rolling own reason.
Comments
Post a Comment