How to implement only one user can access a certain the page - MVC 3 - asp.net-mvc-3

I have a page for editing product details. I want to restrict that only one user can edit the product page. When a new user opens it while there is a current user editing it, I would like to place some notification then automatically make it available once the current user leaves the page. Any suggestion on how I should approach this?

I would recommend just letting them both edit at the same time.
If you want to notify the last person to save their document, then you can add a "version" column to the database.
Upon saving, you would check the version column, to ensure that the row had not been changed. If it had been changed, you would notify the user at that point.

If i understand you question correctly it sounds like you need to know about database concurrency,
Here are a couple of articles:
MSDN
Ironspeed
Now if you are asking how to authorize only a single user to edit records then you would need to look at roles and aloow say only admins to edit records.

you can have optimistic lock on your record while it is in edit mode , once it is saved make that record avaliable for other user.

Try something like this:
Create a table something like userAccess with IsAccessColumn
if user 1 access edit page set isAccess to True
So the second user will not access the edit page if records is set to true.
Then Set to False if user 1 finally edited the record
After that user 2 can now open edit page.
Regards

Related

How to display record in custom created related list of all users having same manager in servicenow

I want to display the record in custom created related list of all users having saming manager in servicenow. For e.g. Abel, Jack has manager Adel, so when I open Adel record I should be able to see the Abel user and Jack user.
This is the script I used and don't know how it will execute in related list:
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name','abel');
gr.query();
gr.next();
gs.print(gr.getDisplayValue('manager'));
I tried this is in Scripts Background option in Application Navigator
You shouldn't need to code for this. If you want to add a related list of user's the current user manages. It will list as "Users" but you can change that label in the related list configuration.
If you meant to do this by code, you'd need to a scripted relationship the data. Here's some information on that. https://docs.servicenow.com/bundle/newyork-platform-user-interface/page/administer/form-administration/task/t_CreateDefinedRelatedLists.html

Laravel: not allow multiple user to update the same database record

In Laravel is there any way to lock particular record with the user and don't allow another user to edit the same record.
For example, User A edit a record R1. This record will lock for the other Users. At the same time, if any other user tries to edit the record R1 then it show the error message at front-end that 'User A is currently editing this record.' and not allow to update the record.
By default MySQL locks the database when one query updates a record and other queries are made in queue to wait for the current query to finish first.
So basically two users cannot update the same record at the same time. It's not possible.
However if you mean like when a user starts editing a form or something, in that very moment you want to lock all fields of the form in the database so that when other users cannot even access the form until the first user stops editing it then you can go with Stony's answer. Just have a field in the table which gets populated with the id of the user currently editing the form, that way you have a way to check if:
some user is editing the form by checking the field if its null or not
also to fetch the user based upon id and show the message who is editing the form
I advise you to make field nullable and foreign key so that you can use an eloquent relationship to fetch the user easily.
I think you don't mean a Transaction where the table is locked in that moment where the user save something that you don't have inconsistency.
I think in your case you have to make a field in your database in_use. When a user open the edit form you write the user id in that field and lock the form. When the next user enter the form you write a message that user XY is editing the record at the moment. But then you have to look that you unlock the record if the user leave the form / record.
Perhaps something like this could help:
https://packagist.org/packages/tokenly/laravel-record-lock

Can I change permissions for a category in Joomla 2.5 without corrupting asset table?

Can I change work around the Admin Console, and changed the permissions directly in the DB, without corrupting Joomla'a Asset Table?
We are using Joomla 2.5 for a unique application where we had to create thousands of categories. The only issue is that we cannot change the permissions of a particular category using the Admin Console because it times out. We just want to change the permission of Edit from "Inherited" to "Allowed".
The category we are changing the permissions on is not a parent of any other category.
This is not a common task.
Best way is to temporarily increase the execution time in your php.ini file. but still if you want to go ahead and make the changes than it wont corrupt the database unless you commit a blunder.
If the permissions for Create Delete Edit etc are inherited then the values in the rules field will look like this
{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}
And once you make the edit from inherited to Allowed it becomes
{"core.create":[],"core.delete":[],"core.edit":{"1":1},"core.edit.state":[],"core.edit.own":[]}
So core.edit has an array with key 1 and value 1. You can change similarly for others but be careful changing database directly. Remember key one is for Public permission. Similarly if you need to change for manager it becomes
{"core.create":[],"core.delete":[],"core.edit":{"1":1,"6":1},"core.edit.state":[],"core.edit.own":[]}
You can see a key 6 is added with value 1 which means the Manager has rights to edit.Key 1 and 6 are group ids of public and Manager respectively. You can get the group ID's if you go to Users->Groups. Right side id will be displayed for each individual group. So suppose you want edit functionality for publisher which is having group id 5 then the rules column will be like this
{"core.create":[],"core.delete":[],"core.edit":{"1":1,"6":1,"5":1},"core.edit.state":[],"core.edit.own":[]}

Make a form View read-only for specific user groups from front-end in Odoo 8

Is it possible to change the attributes of form view for specific user groups in form view tag, like in form tag, readonly="{('user_group','=','some_group')}">
I need to make a form view read-only for s specific user group but only from front-end. Records are updated from code by that user belonging to that specific user group from back-end. and if i disable updating the records of that model by that user group in my security file, that user is not able to modify the records even from back-end.
Best way to do this is by defining a new group that have only read access on that model and add to that user you will save a lot of typing and a lot of your time.
Because what you really asking is to remove edit write for a specific user.

How to associate row with a user in Parse.com?

How to create a column in parse.com such that I can associate each row with a particular user? Also how to protect each row with the user so that others can not perform data modification on that particular row?
For most purposes, you want a Pointer column to the user.
For securing your data to that particular user, you'll want to look at object-level access control. You should be able to find most of what you need in the guide: https://parse.com/docs/ios/guide#security-object-level-access-control
(There are also similar guides for JS and Android)
Per this link: https://parse.com/questions/data-unique-to-user on the parse site, add a column that is a User to the table you want associate. Then use Parse.user.currentUser() to set that value.

Resources