def signup(): if current_user.is_authenticated: return redirect('/') form = SignUp() if form.validate_on_submit(): user = User(email=form.email.data) user.password = form.password.data user.save() login_user(user) return redirect('/') return render_template('signup.html', signup_form=form)
def __call__(self, form, field): exists = User.objects(email=field.data).first() if self._email_should_exist and not exists: raise ValidationError(self._message or u'Email not found.') if not self._email_should_exist and exists: raise ValidationError(self._message or u'Email exists.')
def get_user(self): return User.objects(email=self.email.data).first()