This is a migrated thread and some comments may be shown as answers.

CRUD based on User Authentication

3 Answers 277 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 31 Jan 2012, 10:46 PM
Hi,

How can I enable or disable CRUD features in a grid based on a php session value? I have a typical user authentication system that allows, for example, users with admin privileges (user level = 1) to perform all crud operations on tables, users with user level 2 can only add and edit existing records, but can't delete records.

PHP sessions containing the user level are created on login, just like this site probably. How can I setup grids so that only certain user levels can delete records? Is there already user authentication built into the datasource or other UI widgets?

If not, I need to be able to enable or disable each CRUD operation type based on the value of a PHP session.....any ideas?

Thanks,

Tony

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 02 Feb 2012, 02:21 PM
Hello Tony,

I am afraid the editing capabilities of the grid cannot be change once grid initialization is finished.
Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tony
Top achievements
Rank 1
answered on 02 Feb 2012, 02:47 PM
OK, but how about prior to initialization? For example, can I load the grid with editing enabled if the value of a php session on the same page =1? And, if the session value=2 disable editing? Seems like that should be possible, maybe even with conditional php code.

if ($_session["admin"] ==1) {
run the editable code
else if ($_session["admin"] ==2) {
run simple grid...no editing

Hope I'm making more sense now. It's going to be hard to create any back-end admin solutions without basic user authentication so I'm hoping a simple solution like this will work. When you create the wrappers for php and other languages please consider some simple way to add user authentication hooks. I'm certain almost everyone using Kendo UI for app development will need to apply basic authentication routines and it would be nice if it were supported out of the box.

Thanks,

Tony
0
Nikolay Rusev
Telerik team
answered on 06 Feb 2012, 09:34 AM
Hello Tony,

The only solution I see now for such scenario is when the page is served on client to have a script which prepares correct grid options and then initialize the grid itself. And on every change of the use the page to be posted back so correct settings to be enabled of the grid. What I mean: /in pseudo code/
$(document).ready(function() {
  var permissions = getSessionInfo() // --> this functions retrieves the permissions depending on session cookie etc.
  var gridOptions = { /*..some default options*/ };
  gridOptions.editable = permissions.allowEdit; // --> define the settions depdnding on auth rules
  ....
  $("#grid").kendoGrid(gridOptions); //--> initlize the grid widget
});


Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Tony
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Tony
Top achievements
Rank 1
Share this question
or