mario595
mario595

Reputation: 3761

Django allauth allowed urls

I just started with a Django project using allauth, I configured the basic settings, without using any 3rd party provider. I've created a basic template for my profile page. Everything is working as expected so far, but if a go to localhost:8000/accounts/profile I can see the page even without log in before. I've tried to look in the documentation how to define which page should require be logged in but I haven't found anything.

Any thoughts? Thanks!

EDIT These are my allauth settings:

#Allauth Config
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_SIGNUP_FORM_CLASS = 'picturesApp.forms.SignupForm'
ACCOUNT_EMAIL_VERIFICATION = 'none'

Upvotes: 1

Views: 341

Answers (1)

suselrd
suselrd

Reputation: 794

One possible way to do what you want is to decorate the view handling your profile page woth 'login_required' decorator.

Example:

from django.contrib.auth.decorators import login_required
urlpatterns = patterns('',
   # MY PROFILE
   url(r'^$',
       login_required(MyProfileDetailView.as_view()),
       name="my_profile"
   )
)

This decorator verifies the user is logged in, otherwise it returns a redirect http response (to the login url).
Hope this helps you.

Upvotes: 1

Related Questions