Gabriel Rossetti wrote:
> Hello everyone,
>
> I'm trying to get a custom auth handler to work but I keep on getting 
> this error when accessing request.user.get_profile() :
>
> DoesNotExist: User matching query does not exist.
>
> I followed the following tutorials :
>
> http://garage.pimentech.net/mdm_src_dj_auth_documentation/
> http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/
>
> Here is my auth handler :
>
>     from proj.app.models import User as MyUser
>     from django.contrib.auth.models import User, check_password
>
>     def authenticate(self, username=None, password=None):
>         try:
>             myUser = MyUser.objects.get(email=username)
>         except MyUser.DoesNotExist:
>             return None
>         pwdValid = check_password(password, myUser.password)
>         if(pwdValid):
>             try:
>                 user = User.objects.get(username=username)
>             except User.DoesNotExist:
>                 user = User(username=username,
>                             email=username,
>                             first_name=myUser.firstName,
>                             last_name=myUser.lastName,
>                             password="none")
>                 user.is_staff = False
>                 user.is_superuser = False
>                 user.save()
>                 myUser.user = user # Not sure if this is really needed, 
> I tried it since it didn't work and it still doesn't
>                 myUser.save() # Not sure if this is really needed, I 
> tried it since it didn't work and it still doesn't
>             return user
>         return None
>
>     def get_user(self, userId):
>         try:
>             return User.objects.get(pk=userId)
>         except User.DoesNotExist:
>             return None
>
> here is my model :
>
> from django.db import models
> from django.contrib.auth.models import User as DjangoUser
>
> class User(models.Model):
>     id = models.AutoField(primary_key=True)
>     firstname = models.CharField(maxlength=20)
>     lastname = models.CharField(maxlength=20)
>     email = models.CharField(maxlength=50)
>     password = models.CharField(maxlength=20)
>     user = models.ForeignKey(DjangoUser, unique=True)
>     #user = models.OneToOneField(DjangoUser, core=True) # This doesn't 
> work either
>
> I really don't see why it doesn't work...does anyone have a clue?
>
> Thank you,
> Gabriel
>
> PS I've already looked at past posts on the subject but the common 
> answer is to create the profile, but in my case it's already created, 
> maybe I'm linking it wrong?
>
>   
Am I getting no responses because :

   1) I missing something obvious
   2) I said something wrong
   3) The answer is so simple that no one wants to take the time to write it
   4) No one has a clue
   5) No on has the time
   6) Another reason not listed here

:-)
Gabriel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to