django-authentication

Import PhpBB2 users into django-auth

Is there an elegant way to take the phpbb user table from the version 2 series, and import the users into my django auth_users table? I'm looking to outright dumb the old table completely, but don't want to lose the users. I'm aware that the password column is just a md5 hash of the user's password, but inserting the user with md5$$us...

Django: Are row level permissions for instance specific rules, or are they about views?

Sorry for the confusing title. I tried to make it less verbose, but... What I'm wondering is: Does Django's new row level permissions (a) fix the design problem that comes with multi-tenant applications (I don't mean multiple users, but rather multiple instances working with the same db/db schema), or is it (b) just a more complex versi...

Django login cookies for Subdomains with underscores broken in IE8?

In my Django login I always rewrite a logged in users url to have their username in it. So if the username is "joe" I rewrite the url to be "joe.example.com". This works great except on IE8 for usernames with underscores like "joe_schmoe". IE8 won't login the users when the url is like: "joe_schmoe.example.com". In my settings file I...

Subdomain not included in the "?next=" for Django auth login?

I have a login required page at: http://site1.example.com/widget/52312 If I email someone that link for them to click on, they get sent to the Login prompt. But after they login they end up going to http://example.com/widget/52312. How do you keep the subdomain in the site preserved when a user gets prompted through a login process...

django auth_views.login and redirects

Hello I could not understand why after logging in from address: http://localhost/en/accounts/login/?next=/en/test/ I get refirected to http://localhost/accounts/profile/ So i ran search in django files and found that this address is the default LOGIN_REDIRECT_URL for django. What i did not understand is why it gets redirected to...

What is the opposite of @login_required decorator for Django views?

If I want to make sure that a view is listed as having public access, is there a decorator equivalent to @public_access which would be the opposite of @login_required and make it clear that the view should be publicly accessible always? One use case I have in mind is to automatically add "@csrf_exempt" to all public views in addition to...

Django login redirect not working?

I go to my webpage http://localhost:8000/listings/post/, it fails the test @user_passes_test(lambda u: u.is_authenticated() and u.get_profile().shipper) as expected, and redirects me to http://localhost:8000/login/?next=/listings/post/ like it's supposed to, but when I log in again, it doesn't redirect me back to that page like it's ...

How do I set session variables at login using django-registration and auth?

I'm using django-registration to log users into my application. That part works fine. The part that I cannot figure out is how to set custom session variables when the user logs in. For instance, I'd like to populate variables containing UserProfile data as well as the output of a few other functions. Then I'd be able to use that inf...

Django: Completely custom auth question. Please help.

I'm creating a multiple-tenant application that won't use any of the standard Django Admin (except for internal use which will have access to all tenants... that's simple enough). I'm trying to create an authorization system of my own and I'm not interested in using the standard User model (or any built-in application's model). My applic...

Django: Using custom AUTH system, why is the User model always still needed?

I'm developing an SAAS and having the hardest time wrapping my brain around why I need to use "User" for anything other than myself. I don't know why but it makes me queezy to think that I, as the developer/admin of the entire software, with full Django Admin access (like the Eye of Sauron), have the same type of User object as an "Accou...

Override default get_absolute_url on User objects?

I'm trying to make a generic table for listing django_tables objects. I've got everything working, except that the get_absolute_urls() on my User objects returns: /users/<username>/ While I could create this URL, it doesn't match with the rest of the site layout, so I'm looking for another way to do this. Is there a way to override ...

In Django, why is user.is_authenticated a method and not a member variable like is_staff

Hello all, I've lost some time with a bug in my app due to user authentication. I think that it's a bit confusing but maybe someone can explain the reason and it will appear to me very logical. The user.is_staff is a member variable while user.is_authenticated is a method. However is_authenticated only returns True or False depending i...

django auth - has_perm returns True while list of permissions is empty

Hi, I'm wondering why this code section prints out the following: print "request.user.has_perm('bug_tracking.is_developer'): " + str(request.user.has_perm('bug_tracking.is_developer')) print request.user.get_all_permissions() request.user.has_perm('bug_tracking.is_developer'): True set([]) I would expect that req...

Refactoring a custom User model to user UserProfile: Should I create a custom UserManager or add user.get_profile() dozens of times?

I have been refactoring an app that had customized the standard User model from django.contrib.auth.models by creating a UserProfile and defining it with AUTH_PROFILE_MODULE. The problem is the attributes in UserProfile are used throughout the project to determine what the User sees. I had been creating tests and putting in this type ...

Can django's auth_user.username be varchar(75)? How could that be done?

Is there anything wrong with running alter table on auth_user to make username be varchar(75) so it can fit an email? What does that break if anything? If you were to change auth_user.username to be varchar(75) where would you need to modify django? Is it simply a matter of changing 30 to 75 in the source code?: username = models.CharF...

Django's self.client.login(...) does not work in unit tests

I have created users for my unit tests in two ways: 1) Create a fixture for "auth.user" that looks roughly like this: { "pk": 1, "model": "auth.user", "fields": { "username": "homer", "is_active": 1, "password": "sha1$72cd3$4935449e2cd7efb8b3723fb9958fe3bb100a30f2...

Django design question: extending User to make users that can't log in

The site I'm working on involves teachers creating student objects. The teacher can choose to make it possible for a student to log into the site (to check calendars, etc) OR the teacher can choose to use the student object only for record keeping and not allow the student to log in. In the student creation form, if the teacher supplies ...

Manually logging in a user without password

Hi everybody; I hope you can help me figure the best way to implement a manual (server-side initiated) login without using the password. Let me explain the workflow: User registers Thank you! An email with an activation link has been sent blablabla (Account now exists but is marked not enabled) User opens email, clicks link (Account ...

Django authentication

In my base.html file, I am using {% if user.is_authenticated %} <a href="#">{{user.username}}</a> {% else %} <a href="/acc/login/">log in</a> Here, even if the user is logged in, the log in button shows up. Now when I click on the log in link, it shows the username and also the normal login view, saying user is logged in. So, what's w...

Cannot assign - must be a "UserProfile" instance

I have a class UserProfile defined which takes the default user as a foreign key. Now another class A has a foreign key to UserProfile. So for saving any instance in class A, how do i give it the userprofile object. Also, does making a class UserProfile mean that class user is still used and class UserProfile is just some other table?...