def signup(): if not conf.SELF_REGISTRATION: flash(gettext("Self-registration is disabled."), "warning") return redirect(url_for("home")) if current_user.is_authenticated: return redirect(url_for("home")) form = SignupForm() if form.validate_on_submit(): user = UserController().create( nickname=form.nickname.data, pwdhash=generate_password_hash(form.password.data), ) # Send the confirmation email try: notifications.new_account_notification(user, form.email.data) except Exception as error: flash( gettext("Problem while sending activation email: %(error)s", error=error), "danger", ) return redirect(url_for("home")) flash( gettext("Your account has been created. " "Check your mail to confirm it."), "success", ) return redirect(url_for("home")) return render_template("signup.html", form=form)
def signup(): if not conf.SELF_REGISTRATION: flash(gettext('Self-registration is disabled.'), 'warning') return redirect(url_for('home')) if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): user = UserController().create(nickname=form.nickname.data, email=form.email.data, pwdhash=generate_password_hash( form.password.data)) # Send the confirmation email try: notifications.new_account_notification(user) except Exception as error: flash( gettext('Problem while sending activation email: %(error)s', error=error), 'danger') return redirect(url_for('home')) flash( gettext('Your account has been created. ' 'Check your mail to confirm it.'), 'success') return redirect(url_for('home')) return render_template('signup.html', form=form)
def signup(): if not conf.SELF_REGISTRATION: flash(gettext('Self-registration is disabled.'), 'warning') return redirect(url_for('home')) if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): user = UserController().create(nickname=form.nickname.data, pwdhash=generate_password_hash(form.password.data)) # Send the confirmation email try: notifications.new_account_notification(user, form.email.data) except Exception as error: flash(gettext('Problem while sending activation email: %(error)s', error=error), 'danger') return redirect(url_for('home')) flash(gettext('Your account has been created. ' 'Check your mail to confirm it.'), 'success') return redirect(url_for('home')) return render_template('signup.html', form=form)
def signup(): if not conf.AUTH_ALLOW_SIGNUP: flash(gettext("Self-registration is disabled."), 'warning') return redirect(url_for('home')) if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): user = UserController().create(login=form.login.data, email=form.email.data, password=form.password.data) login_user_bundle(user) return redirect(url_for('home')) return render_template('signup.html', form=form)
def signup(): """ Signup page. """ if int(os.environ.get("SELF_REGISTRATION", 0)) != 1: flash(gettext("Self-registration is disabled."), 'warning') return redirect(url_for('home')) if g.user is not None and g.user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): role_user = Role.query.filter(Role.name == "user").first() user = User(nickname=form.nickname.data, email=form.email.data, pwdhash=generate_password_hash(form.password.data)) user.roles = [role_user] db.session.add(user) try: db.session.commit() except IntegrityError: flash(gettext('Email already used.'), 'warning') return render_template('signup.html', form=form) # Send the confirmation email try: notifications.new_account_notification(user) except Exception as error: flash( gettext('Problem while sending activation email: %(error)s', error=error), 'danger') return redirect(url_for('home')) flash( gettext('Your account has been created. ' 'Check your mail to confirm it.'), 'success') return redirect(url_for('home')) return render_template('signup.html', form=form)
def signup(): """if not conf.SELF_REGISTRATION: flash("Self-registration is disabled.", 'warning') return redirect(url_for('index'))""" if current_user.is_authenticated: return redirect(url_for('index')) form = SignupForm() if form.validate_on_submit(): user = User(name=form.name.data, email=form.email.data, pwdhash=generate_password_hash(form.password.data), is_active=True) db.session.add(user) db.session.commit() flash('Your account has been created. ', 'success') login_user_bundle(user) # automatically log the user return form.redirect('index') loginForm = LoginForm() return render_template('join.html', loginForm=loginForm, signupForm=form)
def signup(): """ Signup page. """ if int(os.environ.get("SELF_REGISTRATION", 0)) != 1: flash(gettext("Self-registration is disabled."), 'warning') return redirect(url_for('home')) if g.user is not None and g.user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): role_user = Role.query.filter(Role.name == "user").first() user = User(nickname=form.nickname.data, email=form.email.data, pwdhash=generate_password_hash(form.password.data)) user.roles = [role_user] db.session.add(user) try: db.session.commit() except IntegrityError: flash(gettext('Email already used.'), 'warning') return render_template('signup.html', form=form) # Send the confirmation email try: notifications.new_account_notification(user) except Exception as error: flash(gettext('Problem while sending activation email: %(error)s', error=error), 'danger') return redirect(url_for('home')) flash(gettext('Your account has been created. ' 'Check your mail to confirm it.'), 'success') return redirect(url_for('home')) return render_template('signup.html', form=form)