def register(login_failed=False, **kwargs): if current_user.is_authenticated(): return redirect(request.referrer or '/') form = RegisterForm() ds = get_extension('security', app=current_app).datastore if form.validate_on_submit(): user = ds.create_user( fullname=form.fullname.data, email=form.email.data, password=form.password.data) ds.commit() login_user(user) ds.commit() flash('Account created successfully', 'info') return index(show_modal='profile') if form.errors: show_modal = 'signup' else: show_modal = None return index(register_form=form, show_modal=show_modal)
def register(login_failed=False, **kwargs): if current_user.is_authenticated(): return redirect(request.referrer or '/') form = RegisterForm() ds = get_extension('security', app=current_app).datastore if form.validate_on_submit(): user = ds.create_user(fullname=form.fullname.data, email=form.email.data, password=form.password.data) ds.commit() login_user(user) ds.commit() flash('Account created successfully', 'info') return index(show_modal='profile') if form.errors: show_modal = 'signup' else: show_modal = None return index(register_form=form, show_modal=show_modal)
def __call__(self, form, field): if get_extension('security').datastore.find_user(email=field.data): raise ValidationError(self.message)