In Django, how do I know the currently logged-in user?

Where do you need to know the user? In views the user is provided in the request as request.user. For user-handling in templates see here If you want to save the creator or editor of a model’s instance you can do something like: model.py class Article(models.Model): created_by = models.ForeignKey(User, related_name=”created_by”) created_on = models.DateTimeField(auto_now_add = True) … Read more

Best Solution For Authentication in Ruby on Rails [closed]

AuthLogic appears to be the new kid on the block and seems to be the next evolution of restful_authentication, easier to use, etc http://github.com/binarylogic/authlogic/tree/master Edit: now that Rails 3 is out, Devise seems to be the new, new kid on the block https://github.com/plataformatec/devise or I have been rolling my own authentication now with the has_secure_password … Read more

Accepting email address as username in Django

For anyone else wanting to do this, I’d recommend taking a look at django-email-as-username which is a pretty comprehensive solution, that includes patching up the admin and the createsuperuser management commands, amongst other bits and pieces. Edit: As of Django 1.5 onwards you should consider using a custom user model instead of django-email-as-username.

Django: signal when user logs in?

You can use a signal like this (I put mine in models.py) from django.contrib.auth.signals import user_logged_in def do_stuff(sender, user, request, **kwargs): whatever… user_logged_in.connect(do_stuff) See django docs: https://docs.djangoproject.com/en/dev/ref/contrib/auth/#module-django.contrib.auth.signals and here http://docs.djangoproject.com/en/dev/topics/signals/

How can I retrieve Basic Authentication credentials from the header?

From my blog: This will explain in detail how this all works: Step 1 – Understanding Basic Authentication Whenever you use Basic Authentication a header is added to HTTP Request and it will look similar to this: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Source: http://en.wikipedia.org/wiki/Basic_access_authentication “QWxhZGRpbjpvcGVuIHNlc2FtZQ==” is just “username:password” encoded in Base64(http://en.wikipedia.org/wiki/Base64). In order to access headers and … Read more