Re: automatically login after email confirmation

2006-10-09 Thread SanPy

Joseph Kocherhans wrote:
> > Does anyone know of a way to login a user without having to
> > authenticate first? Or authenticating with an encrypted password?
>
> The problem is probably that the user.backend attribute does not
> exist. As a hack, you could just set it.
>
> user.backend = 'django.contrib.auth.backends.ModelBackend'
> login(request, user)

Thanks Joseph, now it's working!

Sander


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



Re: Re: automatically login after email confirmation

2006-10-09 Thread Joseph Kocherhans

On 10/9/06, SanPy <[EMAIL PROTECTED]> wrote:
>
> Chris Moffitt wrote:
> > >
> > I've was tripped up by this too.  Can you try something like this:
> >
> >   user = authenticate(username=data[*'user_name'*], 
> > password=data[*'password'*])
> >   login(request, user)
> >
> > This seems to work for me.  If you want to see the full code, it's here -
> > http://satchmo.python-hosting.com/file/trunk/satchmo/shop/views/account.py
> >
> > -Chris

[snip]

> Does anyone know of a way to login a user without having to
> authenticate first? Or authenticating with an encrypted password?

The problem is probably that the user.backend attribute does not
exist. As a hack, you could just set it.

user.backend = 'django.contrib.auth.backends.ModelBackend'
login(request, user)

There really ought to be nice way for django to deal with this
situation, I have some ideas, but it will be awhile before I get
around to implementing them.

Joseph

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



Re: automatically login after email confirmation

2006-10-09 Thread SanPy

Chris Moffitt wrote:
> >
> I've was tripped up by this too.  Can you try something like this:
>
>   user = authenticate(username=data[*'user_name'*], 
> password=data[*'password'*])
>   login(request, user)
>
> This seems to work for me.  If you want to see the full code, it's here -
> http://satchmo.python-hosting.com/file/trunk/satchmo/shop/views/account.py
>
> -Chris

Thanks Chris, I tried this. The problem is that a that particular line
I don't have access to the 'real ' password. In my app, the user
registers by choosing a username and password and email, the password
gets encrypted, and all values are stored. Then, the user press an
activation link in the received confirmation email. In the confirm
view, the user status gets updated to active, and then I want to
perform a login. Maybe, I have to authenticate just before the login
method call, but I don't have access to an unencrypted password there.
Does anyone know of a way to login a user without having to
authenticate first? Or authenticating with an encrypted password?


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



automatically login after email confirmation

2006-10-08 Thread SanPy

I've been trying to implement the user registration process from
http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration .
It's basically a registration process where the user has to be
activated by clicking on a link in an email. Everything went fine and
it worked. Then I wanted to login automatically after the user clicks
on the link in the email.

I use this view for that:
def confirm(request, activation_key):
if request.user.is_authenticated():
return render_to_response('login/confirm.html', {'has_account':
True})
user_profile = get_object_or_404(UserProfile,
 activation_key=activation_key)
if user_profile.key_expires < datetime.datetime.today():
return render_to_response('login/confirm.html', {'expired':
True})
user_account = user_profile.user
user_account.is_active = True
user_account.save()
user = User.objects.get(pk=user_account.id)
if user is not None:
login(request, user)
return render_to_response('login/confirm.html', {'success': True})

I get the following error:
Request Method: GET
Request URL:
http://localhost:8000/accounts/confirm/080784d003e4cc87d63e0dad2fdcf5ffac3b9de8/
Exception Type: AttributeError
Exception Value: 'User' object has no attribute 'backend'
Exception Location:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/contrib/auth/__init__.py
in login, line 53

The exception is thrown from login(request, user). Can somebody help me
out on this issue?


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