Friday, July 18, 2014

LightSwitch 2013 HTML5: Using authorization in LightSwitch application

For authorization we allow some roles and deny some roles, let’s say we are allowing only those users who are in admin group as follows;





Once authorization tag is added in Web.config file, we need to create authorization controller which will be having method to get if authorization true/false for the users. So create following method in authController.cs;




















Last step is reading the value from controller, usually we get the requirement  for enable/disable screen button as per the role/authorization. So for above example we will create simple button on the HTML screen which will redirect to
OrderDetails on click and button will be enable only if the user is in AdminGroup role.











Note: Please add routing mechanism for api's in Global.asax as follows;





















So in this way we can achieve authorization in LightSwitch HTML5.

No comments:

Post a Comment