Hello everyone 
I've been trying to create a custom Authentication Backend in Django , It 
worked .. And it returns an authenticated user and It Logs-in successfuly, 
BUT , whenever I refresh the page or move for another page it just logout ! 
it doesn't stuck logged in . 
here's the backend snap : 

from django.contrib.auth.models import User
class SBAT(ModelBackend):
def authenticate(self, username=None, id=None):
try :
user = User.objects.get(username= username)
if user.id  == id :
return user
except :
return None 
def get_user(self ,user_id ):
try :
user = User.objects.get(pk=user_id)
except : 
return None 


the login view 
....        
        profile_name = profile_data['name']
profile_id = profile_data['id']

try :   
user = User.objects.get(username=profile_name+profile_id[:3])
except : 
user = User.objects.create_user(username=profile_name+profile_id[:3], id = 
int(profile_id))
        user = authenticate(username=user.username , id = int(profile_id) )
login(request,user)
        return render(request,'index.html')

It Login successfully but logout whenever I get out of the current page . 
Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/693224b8-ac95-4d3b-9bcd-800544a34087%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to