So on many sites I see when you register via a simple registration
form that doesn't require email confirmation, then it just logs you in
automatically after registering. Which is nice and cool.

So I added a quick little thing to T2's register() function to do
this. Let me know if you guys like it or have any plans to merge
upstream. Or if i did it wrong!

So below is my new register function. key changes are after the '#auto
login' comment

def register
(self,verification=False,sender='',next='login',onaccept=None,auto_login=False):
        """
        To use, create a controller:

             def register(): return t2.register()
        """
        request,response,session,cache,T,db=self._globals()
        def onaccept2(form):
            db.t2_membership.insert(person_id=form.vars.id,\
              group_id=db.t2_group.insert(name=form.vars.name),\
              status='approved')
            if auto_login and not verification:
                #auto login
                session.t2.person_id=form.vars.id
                session.t2.person_name=form.vars.name
                session.t2.person_email=form.vars.email
                session.flash=self.messages.logged_in

            if form.vars.registration_key:
                body=self.messages.register_email_body % dict
(form.vars)
                if not self.email(sender=sender,to=form.vars.email,\
 
subject=self.messages.register_email_subject,
                                  message=body):
                    self.redirect
(flash=self.messages.unable_to_send_email)
                session.flash=self.messages.email_sent
            if onaccept: onaccept(form)
        vars={'registration_key': str(uuid.uuid4()) if verification
else ''}
        return self.create(self.db.t2_person,vars=vars,\
                           onaccept=onaccept2,next=next)


Thanks,
Nemanja
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to