On Tuesday 30 September 2008, Bjarni Ragnarsson wrote:
> Hi everyone.
>
> I really need to be able to authenticate users directly in code
> knowing only the user name. That is, password is unknown. The user
> is authenticated outside the web.
>
> How can this be accomplished (without hacking TG code)?
> I have TG 1.0b.
Something like this might help. I assume you generate a URL for your users.
Here is my code that works just fine. It's used for emails (newsletter) sent
out to users and
I put a URL in it so the user can log in without typing a password.
So when generating the mail, I create a key which I store in the database along
with the user's name
The code below is what happens when the user clicks on the provided link:
def signup_mail(self,*args,**kw):
if identity.current.anonymous:
# log him in
rec=PendingSignup.get(kw.get('vkey',None))
if not rec:
raise redirect('/signup_mail_failed')
user=User.get(rec.uid)
if not user:
raise redirect('/signup_mail_failed')
i=identity.current_provider.validate_identity(user.user_name,
user.password,
identity.current.visit_key)
identity.set_current_identity(i)
At this point the user is logged in.
Hope that helps
Uwe
--
Open Source Solutions 4U, LLC 1618 Kelly St
Phone: +1 707 568 3056 Santa Rosa, CA 95401
Cell: +1 650 302 2405 United States
Fax: +1 707 568 6416
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---