Edit a node via code authentication I'm creating a website and I have to give the possibility for an anonymous user to update a node. The node is recognized through the use of a code, code that I am sending to the user when the node is saved for the first time. And when I save this node (for the first time), the node is modified to ensure that it is owned by user X and not by anonymous. Ok, is a little complicated, but these are the requests from my client.

So, I send to the user a mail with this line into: http://DOMINIO.EXT/node/123/edit/codeSHA1.

My problem is that Drupal obviously tells me that access is denied to perform the edit operation (node uid is X, but I'm uid 0) when I click onto that link (in my email client). 

How can I resolve this "problem"? I don't want to install TAC or TACLITE, but I can write PHP code into one of my custom module.
Here is a solution using custom coding.


Store all hash codes that are the access code to the DB (I think you do this already), a word of caution do not do md5(node id) or sha1(node id) as anyone will be able to figure it out.
Enable anonymous users to edit the content type they are submitting where the code is needed to edit the node. I know what this mean, keep reading.
Create a custom module where you are going to use the NODE API to intercept the node edit step.


If Drupal 6:  http://api.drupal.org/api/drupal/developer%21hooks%21core.php/function/hook_nodeapi/6

function YOUR-MODULE-NAME_nodeapi(&amp;$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'prepare':

    // Add PHP Code here to validate the hash code
    // You can use an if/else condition to print an access denied message
    // if the code is not valid or expired

    break;
  }
}


If Drupal 7: http://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_prepare/7

function YOUR-MODULE-NAME_node_prepare($node) {
    // Add PHP Code here to validate the hash code
    // You can use an if/else condition to print an access denied message
    // if the code is not valid or expired
}


And that is all.