senchalabs/connect — pull request #879 by pilwon (2013-08-29 02:56:31+00:00)
Title: Fixed "req.session._csrf" getter property redefinition bug.

The line `delete req.session._csrf;` in `lib/middleware/csrf.js` does not work property as `_csrf` is a getter property defined using `Object.defineProperty`. As a result, property redefinition error occurs when the inner function `createToken()` is called the second time.

This PR fixes the bug by setting `configurable` attribute to descriptor during property creation. (as advised in [Mozilla Doc - Object.defineProperty: Modifying a property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#Modifying_a_property))

When the property already exists, Object.defineProperty() attempts to modify the property according to the values in the descriptor and the object's current configuration. If the old descriptor had its configurable attribute set to false (the property is said to be "non-configurable"), then no attribute besides writable can be changed. In that case, it is also not possible to switch back and forth between the data and accessor property types.

If a property is non-configurable, its writable attribute can only be changed to false.

A TypeError is thrown when attempts are made to change non-configurable property attributes (besides the writable attribute) unless the current and new values are the same.