Serenity: HasRole

Created on 19 Oct 2016  路  7Comments  路  Source: serenity-is/Serenity

Hello @volkanceylan,
how can I use the HasRole function from PermissionService.cs in my own grid file?
I can use the Authorization.hasPermission but it doesn't check on role (string).
By the way, when I check by this f.or example: if (Authorization.hasPermission("Contracts:General")) then I get an error in firebug: An invalid or illegal string was specified or the following error: Error: Can't load script data: RemoteData.UserData!
throw new Error(Q.format("Can't load script data: {0}!", name));
What am I doing wrong?

Thanx in advance.

Most helpful comment

@mrsjakie
if you want to use hasRole in typescript, try :

  • add roles property in UserDefinition,ScriptUserDefinition
  • get Roles and set it to ScriptUserDefinition in your UserEndpoint.GetUserData()
  • add function in Authorization.ts that checks for role

I did it in my project. hope this give a clue to solve your problem.

All 7 comments

There is no HasRole functionality. Use permissions.

Check service side error code in network tab.

Hello @volkanceylan. Thank you for the answers. The error about the remotedata is Authorization denied. I don't get this because the user has this explicit permission. When I remove the line the user can access the rows. Very strange.
Can you tell me what the function HasRole in permissionservice.cs is used for?

Thanks in advance.

@mrsjakie
if you want to use hasRole in typescript, try :

  • add roles property in UserDefinition,ScriptUserDefinition
  • get Roles and set it to ScriptUserDefinition in your UserEndpoint.GetUserData()
  • add function in Authorization.ts that checks for role

I did it in my project. hope this give a clue to solve your problem.

Thank you @adhikamafran, I appreciate your mail with a solution.

@adhikamafran, can you please send me the mail with solution file for this issue #1327 ? My emailId is [email protected]. Thanks in advance.

@adhikamafran can u plz email me solution too

thx

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Amitloh picture Amitloh  路  3Comments

stixoffire picture stixoffire  路  3Comments

StefanTheiner picture StefanTheiner  路  3Comments

GitHubOrim picture GitHubOrim  路  3Comments

Shraddha996 picture Shraddha996  路  3Comments