stephenmcd / filebrowser-safe

File manager for Mezzanine
Other
41 stars 104 forks source link

Modify the flash_login_required decorator to support custom authentication #119

Closed Olorin92 closed 5 years ago

Olorin92 commented 5 years ago

Currently, the flash_login_required decorator assumes that the user is utilizing Django authentication - attempting to get the user ID from the _auth_user_id session variable.

However, if another authentication scheme is being used, this variable will potentially not be set, and so causes the upload process to throw an exception and fail.

The easiest way around this is to inspect the request.user property and check to see if it has been set - if it has, we assume a middleware above has set it, and we'll use the ID of this user. If not, we fallback to checking the session variable as usual.

stephenmcd commented 5 years ago

See ff781dd662352d6815f4a995d4246fc713c802ab

Olorin92 commented 5 years ago

Great, that works too - thanks!