MVC 5 - Roles - AuthorizeAttribute outdated
Asked Answered
G

1

0

In my previous post i asked how to check/add user roles, but now i face another problem. Since microsoft moved to the new Identity 2.0, AuthorizeAttribute doesn't work anymore.

Is there any substitute filter for the Authorize?

EDIT:

I've made some tests and [Authorize(Users = "SOME_ID")] works, but not [Authorize(Roles = "Admin")].

And i verified if the user was really in that role (Admin)

Grisham answered 9/9, 2014 at 11:8 Comment(1)
Authorize works fine. Internally it is checking the claims cookie for the existence of a role. You should post your code where you give the user his claims and make sure the roles are in there.Polygamy
T
1

Actually [Authorize(Roles = "ROLENAME")] working fine.

Check your userRoles (or AspNetUserRoles) table for assigned roles for the id your have used that is SOME_ID according to your question. If not you have to correctly assign role "Admin" to the users when you create users.

hope this helps.

Thanet answered 10/9, 2014 at 11:44 Comment(2)
Well, i messed up with the Indentity 2.0... I tried to install identity 1.0 and some methods stopped working. When i removed the messed up files i also deleted the old asp tables and forgot to populate the new ones.Grisham
I noticed the role name is case sensitive tooFullrigged

© 2022 - 2024 — McMap. All rights reserved.