New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request.user.is_active == false #57
Comments
@XuyuanGuo I believe the user being active is set in your DB as an attribute on the user. You'd need to make sure on signup they get marked as active, or activate them later at some point in your user account creation flow. Let me know if you have any other questions. |
@garrypolley Thank you for replying. I created my user account as an administrator in mongodb shell and login with it in settings.py: |
We may be speaking of activate differently. You'll need to make sure the user you created is active. This should likely be done outside of anything around django-mongonaut. See the django doc for creating a super-user: https://docs.djangoproject.com/en/dev/ref/django-admin/#createsuperuser If it's just getting the active set I've done this: python manage.py shell
from my_user_package.model import User
my_user = User.objects.get(username='MY_USERNAME')
my_user.active = True
my_user.save() That should be all you need if that's your issue. |
@garrypolley Then how do you actually login with that 'user'? |
The short version, just login. Depends on the application. Right now the urls are not protected with auth, so you should be able to just go to them. I've done a hack to ensure the user is logged in, but logging in to your site is dependent on your setup. |
Ok, my problem is this: |
Right now we have an open issue for login #40 For now this is what I've done to require login: #urls.py file
def add_decorator(f):
@wraps(f)
@login_required # This can be any decorator you want to use to protect your view
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
return wrapper
# Put auth around monognaut urls
mongonaut_urls = include('mongonaut.urls')
for url_pattern in mongonaut_urls[0].urlpatterns:
url_pattern._callback = add_decorator(url_pattern._callback) This is a bit of a hack to protect all the urls in the app. I've had a separate conversation with someone about how 3rd party apps should protect urls and it's not an easy answer. |
If you don't have anymore questions I'll close this issue out. |
Thank you for your reply. Go ahead and close it. |
A few points:
|
When I do:
The "request.user.is_authenticated" is true. But the "request.user.is_active" is false, which prevents me from accessing the admin site.
Why my user is not active and how can I fix that, pydanny?
Thanks.
The text was updated successfully, but these errors were encountered: