Esempio n. 1
0
    def activate_token(self, token):
        u = User(_DBCON)
        if u.activate(token):
            self._login_user(u)

        else:
            self.viewdata.update({
                'error':'The token does not match any account that is pending activation'
            })

            return self._template('error')
Esempio n. 2
0
    def register_post(self):
        e = bottle.request.POST.get('email')
        p1 = bottle.request.POST.get('password1')
        p2 = bottle.request.POST.get('password2')
            
        if e and p1 and p2:
            if p1 != p2:
                self.viewdata.update({
                    'error':'The passwords do not match', 
                    'email':e, 
                    'password1':p1,
                    'password2':p2,
                })
                return self._template('register')
            else:
                u = User(_DBCON, email=e, password=p1)
                if u._id:
                    self.viewdata.update({
                        'error':'An account already exists for that email address', 
                        'email':e, 
                        'password1':p1,
                        'password2':p2,
                    })

                    return self._template('register')
                else:
                    u.save()
                    e = Email(recipient=e)
                    e.send('Places accounts activation', '<a href="%s/activate/%s">Activate</a>' % (settings.BASEURL, u.token))

                    return bottle.redirect('/success')
                    
                    
        else:
            self.viewdata.update({
                'error':'Please complete the form', 
                'email':e, 
                'password1':p1,
                'password2':p2,
                })

            return self._template('register')