What is the best way to empower users to edit only their own content?

Currently, I am developing a website using JavaScript and C#. I am connecting the two languages by utilizing generic handlers.

My goal is to allow users to delete or edit their own content while displaying the same data to everyone. For instance, when a user is logged into the website's homepage, they should be able to delete their own questions.

How can I achieve this functionality without compromising security? One idea I had was to keep a cookie and validate it with each request.

For example, how does Facebook enable users to only delete their own comments and not others'? Do they track individual sessions for each user?

If you have any insights or suggestions, please share!

Answer №1

It is important to only grant users access to CRUD functions when they are logged in. Additionally, the editing and deleting functions should verify that the user owns the content before making any changes. Furthermore, the UI for editing or deleting content should only be displayed if the user is the rightful owner.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The issue of `window.scrollTo(0, 240)` not functioning properly when used in combination with

I am currently in the process of developing a website using Reactjs and Gatsby. The issue I'm facing is that when I have window.scrollTo(0, 240) within the componentDidMount() function, everything works fine when I refresh the site. However, when I n ...

Leveraging the outcome of JSON within PHP variables

I would like to completely rewrite my question. My goal is to update the display of five variables without having to reload the entire page. I have a PHP file called check_conf_update.php which executes a query, retrieves data, and converts it into JSON ...

Bootstrap Thumbnail Grid - dynamic loading with ajax

Situation: I am facing a challenge where I have a view displaying countries in a twitter bootstrap thumbnail grid. Upon clicking an image, the intention is to dynamically show cities related to that particular country within the same grid on the screen. T ...

Issue with retrieving POST body from Ajax call in Play Framework

I am currently attempting to send a POST request to my backend using JSON data. The frontend call appears like this: function register() { var user = $("#form_reg_username").val(); var pass = $("#form_reg_password").val(); var referal = $("#form_reg ...

How to effectively combine css() and delay() in jQuery?

fid: https://jsfiddle.net/k13sazuz/ Is there a way to create a delay chain for CSS rules using jQuery? $('.two').css('background','blue').delay(11800).css('background','red'); ...

Steps for updating a table following a successful Post request utilizing $evalAsync

I am facing an issue with updating my table after a successful Post without having to reload the page. Interestingly, I have it working perfectly for a successful Put request but seem to be struggling to make it work with the Post request. Works //Update ...

Sending optional data in Angular routesIn Angular, you can include additional

In my project utilizing angular 5, I have a lengthy routing file: const homeRoutes: Routes = [ { path: 'home', component: HomeComponent, children: [ { path: 'registration', component: RegistrationCompone ...

Issues with case sensitivity in Linq operations

I am seeking assistance with a specific issue regarding the use of Linq to execute a query. While I am aware that String.Equals(string) is case sensitive, my tests have shown otherwise when using it within the Linq statement provided below. Despite applyin ...

How does JavaScript manage to be both non-blocking and asynchronous while also being single-threaded?

I'm struggling with understanding how Javascript can maintain a single-threaded nature while still being non-blocking on the client. My current mental model is akin to an assembly line: Imagine a single assembly line at the beginning of code execu ...

Verify if the dates align in javascript

I am currently in the process of developing a custom ASP.Net validator that verifies whether the input data corresponds to a non-working day. For the purpose of this validation, a "non-working day" is defined as follows: The date falls on either a Satur ...

The requested cast is invalid when converting SQL Server data to an array

Database: When attempting to transform SQL Server data into an array, I encountered an issue: Invalid specific cast error This is the code I used: string query = "select part1,part2,part3 from Table_3 where id ='" + textBox1.Text + "'"; int ...

What is the method to access 'let' variables in the console of a developer tool?

When you open the Chrome devtool and enter the code snippet below: // The iife is irrelevant let r = (() => { return 2; })(); and then evaluate r, the output will be: r 2 Surprisingly, both window.r and globalThis.r return undefined. Although let is ...

What is the best way to establish a connection between Node.js and MySQL (phpMyAdmin)?

While setting up a new version of xampp, I managed to successfully connect my JavaScript script to MySQL using the terminal. const mysql = require('mysql'); let con = mysql.createConnection({ host: "localhost", user: "root", passw ...

Search for an element by its class name after adding it using the append

My current situation involves the following code: $('body').append("<div class='bar'></div>"); var trial = $('.bar'); I am unable to locate bar. What mistake have I made in this scenario? ...

Initiate function by using event broadcaster

Is it feasible to activate a function in a different component from the current one using EventEmitter, acting similar to a callback mechanism? For instance, following the completion of an API request, a successful function is triggered as shown below: @O ...

The Method does not display the view as expected when invoked through jQuery

this is the technique (indeed, it is supposed to return a PartialView) [HttpPost] public ActionResult partial1() { return View(); } that functions when called as follows @using ( Ajax.BeginForm("partial1", "Ho ...

Displaying the chosen array in a Material UI Table within a React application does not show the desired checkboxes

After days of hard work and research, I finally figured out how to achieve what I needed. In my React App, I have a Material UI table that I want to load with pre-rendered checks in the DOM based on entries in a selected array. The selected array contains ...

Decoding JSON objects using JavaScript/jQuery

I am working with a Json object that looks like this. { "firstName":"John", "lastName":"Doe" "123":"456" } My goal is to access the keys and values in order to populate fields. However, for some reason it is not working as expected even though I have ch ...

Discover the same email sent to various recipients in EWS

Consider a scenario with a company email system: incomming@company Emails in: 1-Help Me, 2-Hello person1@company Emails in: 1-Hi Person1, 2-Help Me, 3-Invoice, 4-Hello person2@company Emails in: 1-Help Me, 2-Hello, 3-Fix Bug All emails sent to the inco ...

I can't figure out why my unslider isn't adapting to the screen size. Check out the fiddle for more details

I recently implemented unslider to create a slideshow that spans 100% of the width on my website. Everything seemed to be working fine until I tried resizing the screen, and the slides remained the same size as they were initially loaded. Here is the code ...