コード例 #1
0
def register():
    """
    Register new user.
    """
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        u = User(
            username=form.username.data,
            email=form.email.data,
            password=form.password.data,
            first_name=form.first_name.data,
            last_name=form.last_name.data,
        )
        u.enforce_admin()
        u.save()
        if u.active:
            flash("Thanks for registering! You're now logged in.", "success")
            login_user(u)
        else:
            flash(
                "Thanks for registering! You will now need to wait for your admin to approve this account.",
                "success",
            )
        return redirect(url_for("public.home"))
    else:
        flash_errors(form)
    return render_template("public/register.html", form=form)
コード例 #2
0
ファイル: test_forms.py プロジェクト: yumatchlab/MegaQC
 def test_validate_success(self, db):
     """Register with success."""
     form = RegisterForm(username='******',
                         email='*****@*****.**',
                         password='******',
                         confirm='example')
     assert form.validate() is True
コード例 #3
0
ファイル: test_forms.py プロジェクト: genomicsITER/MegaQC
 def test_validate_success(self, user_attrs, app):
     """Register with success."""
     form = RegisterForm(username=user_attrs.username,
                         email=user_attrs.email,
                         first_name=user_attrs.first_name,
                         last_name=user_attrs.last_name,
                         password='******',
                         confirm='password')
     assert form.validate() is True
コード例 #4
0
ファイル: test_forms.py プロジェクト: yumatchlab/MegaQC
    def test_validate_user_already_registered(self, user):
        """Enter username that is already registered."""
        form = RegisterForm(username=user.username,
                            email='*****@*****.**',
                            password='******',
                            confirm='example')

        assert form.validate() is False
        assert 'Username already registered' in form.username.errors
コード例 #5
0
ファイル: test_forms.py プロジェクト: yumatchlab/MegaQC
    def test_validate_email_already_registered(self, user):
        """Enter email that is already registered."""
        form = RegisterForm(username='******',
                            email=user.email,
                            password='******',
                            confirm='example')

        assert form.validate() is False
        assert 'Email already registered' in form.email.errors
コード例 #6
0
ファイル: test_forms.py プロジェクト: genomicsITER/MegaQC
    def test_validate_email_already_registered(self, user, user_attrs):
        """Enter email that is already registered."""
        form = RegisterForm(username=user_attrs.username,
                            email=user.email,
                            first_name=user_attrs.first_name,
                            last_name=user_attrs.last_name,
                            password='******',
                            confirm='password')

        assert form.validate() is False
        assert 'Email already registered' in form.email.errors
コード例 #7
0
ファイル: test_forms.py プロジェクト: pythseq/MegaQC
    def test_validate_user_already_registered(self, user, user_attrs):
        """
        Enter username that is already registered.
        """
        form = RegisterForm(
            username=user.username,
            email=user_attrs.email,
            first_name=user_attrs.first_name,
            last_name=user_attrs.last_name,
            password="******",
            confirm="password",
        )

        assert form.validate() is False
        assert "Username already registered" in form.username.errors
コード例 #8
0
def register():
    """Register new user."""
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        user_id = (db.session.query(func.max(User.user_id)).scalar() or 0) + 1
        User.create(user_id=user_id,
                    username=form.username.data,
                    email=form.email.data,
                    password=form.password.data,
                    first_name=form.first_name.data,
                    last_name=form.last_name.data,
                    active=True)
        flash("Thanks for registering! You're now logged in.", 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)
コード例 #9
0
ファイル: views.py プロジェクト: vladsaveliev/MegaQC
def register():
    """Register new user."""
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user_cnt = db.session.query(User).count()
        u = User.create(
            username=form.username.data,
            email=form.email.data,
            password=form.password.data,
            first_name=form.first_name.data,
            last_name=form.last_name.data,
            active=True,
            is_admin=True if user_cnt == 0 else False,
        )
        flash("Thanks for registering! You're now logged in.", 'success')
        login_user(u)
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)