def test_confirm_registration(self): t = self.make_team() self.dbsession.add(t) self.dbsession.flush() assert not t.active assert confirm_registration(t.token) assert t.active assert not t.token
def confirm_registration(self): """ After a registration has been made, the team recieves a confirmation mail with a token. With this token the team activates its account by visitng this view. It fetches the team corresponding to the token and activates it. """ if self.request.settings.archive_mode: self.request.session.flash(("Registration disabled in archive " "mode."), 'error') return HTTPFound(location=self.request.route_url('home')) token = self.request.matchdict.get('token', None) if not confirm_registration(token): self.request.session.flash("Invalid token", 'error') raise HTTPFound(location=self.request.route_url('login')) else: self.request.session.flash("Your account is active, you may now " "log in.") return HTTPFound(location=self.request.route_url('login'))
def test_confirm_registration_no_token(self): assert not confirm_registration(None)
def test_confirm_registration_no_team(self): assert not confirm_registration("A" * 20)