Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = LoginForm()
    if form.validate_on_submit():
        login_user_bundle(form.user)
        return form.redirect('index')
    signup = SignupForm()
    return render_template('join.html', loginForm=form, signupForm=signup)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
Archivo: views.py Proyecto: bzero/JARR
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)
Ejemplo n.º 9
0
def join():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = LoginForm()
    signup = SignupForm()
    return render_template('join.html', loginForm=form, signupForm=signup)
Ejemplo n.º 10
0
        name='create_predict_ensemble'),
    url(r'^download/', 'download_from_s3'),
    url(r'^bd_admin/', include(admin.site.urls)),
    url(r'^api/', include('api.urls')),
    url(r'^data/', include('data_management.urls')),
    url(r'^payments/', include('payments.urls')),
    url(r'^help/', include('help.urls')),
    url(r'^api-help/', include('rest_framework_swagger.urls')),
)

urlpatterns += patterns(
    'django.contrib.auth.views',
    url(r'^login/$',
        'login', {
            'extra_context': {
                'signup_form': SignupForm()
            },
            'authentication_form': SigninForm
        },
        name='login'),
    url(r'^logout/$', 'logout', {'next_page': '/'}, name='logout'),
    url(r'^password_reset/$', 'password_reset', name='password_reset'),
    url(r'^password_reset/done/$',
        'password_reset_done',
        name='password_reset_done'),
    url(r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        'password_reset_confirm',
        name='password_reset_confirm'),
    url(r'^reset/done/$',
        'password_reset_complete',
        name='password_reset_complete'),