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)

Community
  • 1
  • 1
Leandro Soares
  • 2,902
  • 2
  • 27
  • 39
  • 2
    `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. – jamesSampica Sep 09 '14 at 13:48

1 Answers1

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.

DSR
  • 4,588
  • 29
  • 28
  • 1
    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. – Leandro Soares Sep 12 '14 at 08:26
  • I noticed the role name is case sensitive too – Diin Jun 14 '15 at 23:14